简体   繁体   中英

Migrating WPF library from .NET Framework to .NET 6

I'm currently migrating my WPF projects from .NET Framework 4.8 to .NET 6 using the .NET Upgrade Assistant as a base and then manually fixing the remaining problems.
All my projects have a shared set of libraries, one of this contains both standard classes and a few custom UserControl . When migrating this particular library to .NET 6 the frameworks referenced by this library are Microsoft.NETCore.App and Microsoft.WindowsDesktop.App . The problem is when I try to use this library in another project I get the following warning:

Warning MSB3277 Found conflicts between different versions of "WindowsBase" that could not be resolved.
There was a conflict between "WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" and "WindowsBase, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35".
"WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" was chosen because it was primary and "WindowsBase, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" was not.

Looking at the WindowsBase referenced by the two frameworks referenced by the library I see that Microsoft.NETCore.App references WindowsBase v4.0.0.0 while Microsoft.WindowsDesktop.App references WindowsBase v6.0.0.0.
How can I solve this?

I met the exact issue as you when upgrading a csharp project from.Net framework to.Net6.

There are some dependencies under assemblies (such as system system.xml ) which directed to the wrong framework path but can not be removed or modified. There was no much information about this issue on csdn so it really took me a while to find the root cause by trial and error, and finally it was the WinFX.Targets file imported in my csproj project file which brough these .net framework dependencies.

The WinFX.Targets file was imported by csproj before upgrading and the importing was deleted by upgrading. It was necessary for the project so I added it back without modification, which caused the MSB3277 build warning.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM