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.
Related
My project called 'Gui Tester' has a microsoft.windowsdesktop.App.WindowsForms framework version 6.0.0. In addition, it has a project reference to WinForms class called 'WinFormsLibrary3' which its framework version 6.0.9. This causes the error below. How do I make both versions the same in order to solve this issue? I was unable to find a way to remove/add/update a framework.
A link to a sample solution (\AssemblyError\GuiTester\GuiTester.sln) can be found here - https://1drv.ms/u/s!AuZvh6FckScbhMpi02_Dm-YCBE00ew?e=KKNyLi
Error CS1705 Assembly 'WinFormsLibrary3' with identity 'WinFormsLibrary3, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Windows.Forms, Version=6.0.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' which has a higher version than referenced assembly 'System.Windows.Forms' with identity 'System.Windows.Forms, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
There is no way your Gui tester project (version 6.0.0) can open your winFormsLibrary3 (version 6.0.9). Since the lower version does not recognize or support a higher version which it never designs for. What you can do is create a new solution of gui tester with a higher version and just copy all the files from the old gui tester into your new gui tester.
As I wrote in the comment, you can try downgrade your target framework, but some times it cause unexpected behaviour
https://ourtechroom.com/fix/how-to-downgrade-net-framework-version-in-visual-studio/
I started a new .NET Framework 4.7.2 library project. I need to automate PowerShell scripts, but the "framework" tab in Visual Studio's reference adding UI didn't list System.Management.Automation as an option. So I added a reference to this Nuget package:
https://www.nuget.org/packages/System.Management.Automation/7.0.0
Then with this code:
PowerShell ps = PowerShell.Create();
ps.AddScript(#"C:\ps\function.ps1");
ps.AddArgument(1);
ps.AddArgument(2);
Collection<PSObject> results = ps.Invoke<PSObject>();
I get this error about versions of a DLL which I did not directly reference:
Assembly 'System.Management.Automation' with identity 'System.Management.Automation, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' uses 'System.Linq.Expressions, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Linq.Expressions' with identity 'System.Linq.Expressions, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
I'm not sure how to resolve this, and I think maybe I approached adding my PowerShell automation library reference the wrong way. What's the right way to do this currently?
Before you point me at an old answer, I found a similar question about this which points to a different Nuget package, now marked "deprecated" and doesn't look official anyway. That makes me nervous.
https://www.nuget.org/packages/System.Management.Automation.dll/
System.Management.Automation v7.0.0 only works with .NET Core. If your project requires .NET Framework, you must use System.Management.Automation v5.1.x.
I use System.Management.Automation.dll in my .net framework 4.7.2 app.
I just added it via the following reference:
C:\WINDOWS\assembly\GAC_MSIL\System.Management.Automation\1.0.0.0__31bf3856ad364e35\System.Management.Automation.dll
I spent 2 days googling, trying to resolve conflict situation with dll versioning in Xamarin. I saw a lot of posts with identical issues (just different NuGet packages) but as I saw, no concrete solution anywhere. I will try to summarize briefly here.
I am using Xamarin for Android (Not Xamarin Forms). This project references my .NET standard 2.0 (.NET Core) project that contains all core logic. I Installed Automapper via NuGet in my core project and suddenly I have build warning that describes the conflict. Conflict is that Xamarin for Android (Mono) uses Microsoft.Csharp.dll version 2.0.5.0 and Auto mapper which is in referenced Core project uses Microsoft.Csharp.dll 4.0.0.0
Here is the output from build process related to mentioned:
There was a conflict between "Microsoft.CSharp, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". (TaskId:131)
2> "Microsoft.CSharp, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not. (TaskId:131)
2> References which depend on "Microsoft.CSharp, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\Microsoft.CSharp.dll]. (TaskId:131)
2> C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\Microsoft.CSharp.dll (TaskId:131)
2> Project file item includes which caused reference "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\Microsoft.CSharp.dll". (TaskId:131)
2> Microsoft.CSharp (TaskId:131)
2> References which depend on "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" []. (TaskId:131)
2> C:\Users\missa\.nuget\packages\automapper\7.0.1\lib\netstandard2.0\AutoMapper.dll (TaskId:131)
2> Project file item includes which caused reference "C:\Users\missa\.nuget\packages\automapper\7.0.1\lib\netstandard2.0\AutoMapper.dll". (TaskId:131) C:\Users\missa\.nuget\packages\automapper\7.0.1\lib\netstandard2.0\AutoMapper.dll (TaskId:131)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3277: Found conflicts between different versions of "Microsoft.CSharp" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.
So, build process has chosen an older version from Xamarin (this is confirmed because I extracted APK to see which dll is physically inside and found 2.0.5.0)
Now, the summary of the questions is:
If I leave the warning and accept current situation, I will have Microsoft.Csharp.dll 2.0.5.0 I suppose Android project is OK with this since it originally references this version, but how will AutoMapper behave since it is built with 4.0.0.0 reference? If it uses some new features, and the old version doesn't have them, it is not good.
Can I somehow force Xamarin to use Microsoft.Csharp.dll 4.0.0.0 since I don't see this reference directly (Mono reference is using it)? I can't use the binding redirect from app.config since Xamarin for Android doesn't support app.config. Even if there is a way somehow, is it smart solution since maybe Microsoft.Csharp 4.0.0.0 is not backward compatible with 2.0.5.0
If 1 or 2 are not good solutions, is it possible somehow (codebase path or something else) to make the situation to have both versions and that every component references its original?
This issue with AutoMapper is just an example, but basically, this case can happen with any other package. I saw that it was actually with NewtonJson and is solved in the new version of NewtonJson package where reference to Miscrosoft.Cshap.dll is removed.
I'm getting an annoying MSB3277 warning when I build my project. I increased verbosity to "detailed" and I was able to get the following information from the log:
There was a conflict between "Pathoschild.Http.Client, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null" and "Pathoschild.Http.Client, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null".
"Pathoschild.Http.Client, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null" was chosen because it was primary and "Pathoschild.Http.Client, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null" was not.
References which depend on "Pathoschild.Http.Client, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null" [C:\Users\desau\.nuget\packages\pathoschild.http.fluentclient\3.0.0\lib\netstandard1.3\Pathoschild.Http.Client.dll].
C:\Users\desau\.nuget\packages\pathoschild.http.fluentclient\3.0.0\lib\netstandard1.3\Pathoschild.Http.Client.dll
Project file item includes which caused reference "C:\Users\desau\.nuget\packages\pathoschild.http.fluentclient\3.0.0\lib\netstandard1.3\Pathoschild.Http.Client.dll".
C:\Users\desau\.nuget\packages\pathoschild.http.fluentclient\3.0.0\lib\netstandard1.3\Pathoschild.Http.Client.dll
References which depend on "Pathoschild.Http.Client, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null" [].
C:\Users\desau\.nuget\packages\stronggrid\0.30.0\lib\netstandard1.3\StrongGrid.dll
Project file item includes which caused reference "C:\Users\desau\.nuget\packages\stronggrid\0.30.0\lib\netstandard1.3\StrongGrid.dll".
C:\Users\desau\.nuget\packages\stronggrid\0.30.0\lib\netstandard1.3\StrongGrid.dll
If I understand this log correctly, it's telling me that my project references Pathoschild.Http.Client version 3.0 and also version 3.1. I understand the reference to version 3.1 because my project references a nuget package called StrongGrid which itself references Pathoschild version 3.1
But I fail to understand where the reference to version 3.0 comes from.
I'm using Visual Studio 2017 and MSBuild 15 in case that's helpful information.
The reason for this issue is that the StrongGrid package is authored incorrectly.
The version 0.30 of StrongGrid is built against version 3.1.0 of Pathoschild.Http.FluentClient, but their .nuspec file used for creating the NuGet package still lists version 3.0.0 as dependency, so the consuming project will fetch an older version, creating a conflict that cannot be resolved.
To work around this problem, you can explicitly reference version 3.1.0 of Pathoschild.Http.FluentClient by adding a package reference to the csproj file to override the version.
I had to downgrade my program from .NET 3.5 to 3.0. What I did was go properties->application and change the "Target Framework" from 3.5 to 3.0. is this the correct step? now I get warnings:
I only have this
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.IO;
but yet I get this
Warning 1 The primary reference "System.Core", which is a framework
assembly, could not be resolved in the currently targeted framework.
".NETFramework,Version=v3.0". To resolve this problem, either remove
the reference "System.Core" or retarget your application to a
framework version which contains "System.Core". ProgName1
Warning 2 The primary reference "System.Xml.Linq" could not be
resolved because it has an indirect dependency on the framework
assembly "System.Core, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" which could not be resolved in the
currently targeted framework. ".NETFramework,Version=v3.0". To resolve
this problem, either remove the reference "System.Xml.Linq" or
retarget your application to a framework version which contains
"System.Core, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089". ProgName1
Warning 3 The primary reference "System.Data.DataSetExtensions" could
not be resolved because it has an indirect dependency on the framework
assembly "System.Core, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" which could not be resolved in the
currently targeted framework. ".NETFramework,Version=v3.0". To resolve
this problem, either remove the reference
"System.Data.DataSetExtensions" or retarget your application to a
framework version which contains "System.Core, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089". ProgName1
Warning 4 The primary reference "System.Xml.Linq", which is a
framework assembly, could not be resolved in the currently targeted
framework. ".NETFramework,Version=v3.0". To resolve this problem,
either remove the reference "System.Xml.Linq" or retarget your
application to a framework version which contains
"System.Xml.Linq". ProgName1
Warning 5 The primary reference "System.Data.DataSetExtensions", which
is a framework assembly, could not be resolved in the currently
targeted framework. ".NETFramework,Version=v3.0". To resolve this
problem, either remove the reference "System.Data.DataSetExtensions"
or retarget your application to a framework version which contains
"System.Data.DataSetExtensions". ProgName1
The warnings are telling you that those five assemblies are new to .Net 3.5 and cannot be referenced from .Net 3.0.
Just delete those references.
It seems you are using Extension methods extensivly and this is one of the main reasons you're getting most of these errors.
You need 3.5 for extension methods.