You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
XAML using the WindowsFormHost control does not build in .NET Core 3 WPF apps. For example, the following XAML builds for .NET Framework but not for .NET Core 3:
We were missing the XMLNS attribute for System.Windows.Controls.Ribbon and System.Windows.Documents.DocumentStructures as well which were fixed in the same commit.
I see, that sounds like a bug with the Microsoft.NET.Sdk.WindowsDesktop implicit references. You can set DisableImplicitFrameworkReferences to true to disable that, then you have to list your references manually on net4x. I'll file the bug in the WPF repo on the SDK targets.
Alternatively, just update it to target net45 instead if your end goal is to get it to core.
I'm running .NET Core SDK 3.1.100 and trying to use WindowsFormsHost from XAML. It's failing to find the tag but from everything mentioned in this thread it should be working. A simple repro:
PS C:\src\Sample> dotnet build
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 33.43 ms for C:\src\Sample\Sample.csproj.
C:\src\Sample\MainWindow.xaml(10,10): error MC3074: The tag 'WindowsFormsHost' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'. Line 10 Position 10. [C:\src\Sample\Sample.csproj]
C:\src\Sample\MainWindow.xaml(10,10): error MC3074: The tag 'WindowsFormsHost' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'. Line 10 Position 10. [C:\src\Sample\Sample.csproj]
Build FAILED.
C:\src\Sample\MainWindow.xaml(10,10): error MC3074: The tag 'WindowsFormsHost' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'. Line 10 Position 10. [C:\src\Sample\Sample.csproj]
C:\src\Sample\MainWindow.xaml(10,10): error MC3074: The tag 'WindowsFormsHost' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'. Line 10 Position 10. [C:\src\Sample\Sample.csproj]
0 Warning(s)
2 Error(s)
Time Elapsed 00:00:01.08
PS C:\src\Sample> dotnet --version
3.1.100
Activity
Work around dotnet/core#2085
ericstj commentedon Nov 29, 2018
Fix for this has been checked into WPF yesterday, leaving this open until fix makes it to the SDK
ericstj commentedon Nov 29, 2018
We were missing the XMLNS attribute for
System.Windows.Controls.RibbonandSystem.Windows.Documents.DocumentStructuresas well which were fixed in the same commit.karelz commentedon Dec 18, 2018
Seems to be addressed, closing.
virzak commentedon Jan 10, 2019
I got latest daily build but can't resolve
System.Windows.Controls.Ribbonwhen using<TargetFrameworks>net40</TargetFrameworks>.Works properly with
<TargetFrameworks>net45</TargetFrameworks>ericstj commentedon Jan 10, 2019
System.Windows.Controls.Ribbon was only introduced in .NET 4.5. https://docs.microsoft.com/en-us/dotnet/api/system.windows.controls.ribbon.ribbon
virzak commentedon Jan 11, 2019
@ericstj is there a way to prevent ribbon it from loading?
Trying to migrate a library to core which previously targeted 4.0
https://github.com/ejensen/toggle-switch-control/blob/master/WPF/ToggleSwitch/ToggleSwitch.csproj#L13
ericstj commentedon Jan 11, 2019
I see, that sounds like a bug with the Microsoft.NET.Sdk.WindowsDesktop implicit references. You can set DisableImplicitFrameworkReferences to true to disable that, then you have to list your references manually on net4x. I'll file the bug in the WPF repo on the SDK targets.
Alternatively, just update it to target net45 instead if your end goal is to get it to core.
adamdriscoll commentedon Jan 4, 2020
I'm running .NET Core SDK 3.1.100 and trying to use
WindowsFormsHostfrom XAML. It's failing to find the tag but from everything mentioned in this thread it should be working. A simple repro:Project
XAML
Output
What am I missing?
ivan2007 commentedon Mar 23, 2021
Add
<UseWindowsForms>true</UseWindowsForms>in your project file