ECS1705 which has a higher version than referenced assembly - c#

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/

Related

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.

What might be causing apparent nuget package self-references?

I have a project file targeting net 472. It depends on a bunch of libraries that are built against netstandard2. Some of those libraries depend upon the Microsoft.Extensions.Primitives library although (as far as I can tell) there is no directly dependency from the root project. When I build it, I see this warning...
Severity Code Description Project File Line Suppression State
Warning Found conflicts between different versions of "Microsoft.Extensions.Primitives" that could not be resolved.
There was a conflict between "Microsoft.Extensions.Primitives, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" and "Microsoft.Extensions.Primitives, Version=5.0.0.1, Culture=neutral, PublicKeyToken=adb9793829ddae60".
"Microsoft.Extensions.Primitives, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" was chosen because it was primary and "Microsoft.Extensions.Primitives, Version=5.0.0.1, Culture=neutral, PublicKeyToken=adb9793829ddae60" was not.
References which depend on "Microsoft.Extensions.Primitives, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" [C:\Users\neilm\.nuget\packages\microsoft.extensions.primitives\5.0.0\lib\net461\Microsoft.Extensions.Primitives.dll].
C:\Users\neilm\.nuget\packages\microsoft.extensions.primitives\5.0.0\lib\net461\Microsoft.Extensions.Primitives.dll
Project file item includes which caused reference "C:\Users\neilm\.nuget\packages\microsoft.extensions.primitives\5.0.0\lib\net461\Microsoft.Extensions.Primitives.dll".
C:\Users\neilm\.nuget\packages\microsoft.extensions.primitives\5.0.0\lib\net461\Microsoft.Extensions.Primitives.dll
References which depend on "Microsoft.Extensions.Primitives, Version=5.0.0.1, Culture=neutral, PublicKeyToken=adb9793829ddae60" [].
C:\Users\neilm\.nuget\packages\lazycache\2.1.3\lib\netstandard2.0\LazyCache.dll
Project file item includes which caused reference "C:\Users\neilm\.nuget\packages\lazycache\2.1.3\lib\netstandard2.0\LazyCache.dll".
C:\Users\neilm\.nuget\packages\lazycache\2.1.3\lib\netstandard2.0\LazyCache.dll
D:\work\code\b6\Backend\CSharp\Libraries\Standard\TableAccess_std\bin\Debug\netstandard2.0\TableAccess_std.dll
D:\work\code\b6\Backend\CSharp\Libraries\Standard\CommsCode_std\bin\Debug\netstandard2.0\CommsCode_std.dll
D:\work\code\b6\Backend\CSharp\Libraries\Standard\Recognisers\bin\Debug\netstandard2.0\Recognisers.dll
The relevant section, elided for readability, is
References which depend on "Microsoft.Extensions.Primitives, Version=5.0.0.0,...
C:\Users\neilm\.nuget\packages\microsoft.extensions.primitives\5.0.0\lib\net461\Microsoft.Extensions.Primitives.dll
Project file item includes which caused reference...
C:\Users\neilm\.nuget\packages\microsoft.extensions.primitives\5.0.0\lib\net461\Microsoft.Extensions.Primitives.dll
which seems to be describing a self-reference. Any idea how this might be occurring? I've tried nuking the package cache, as well as the bin and obj folders but can't seem to get rid of it. TIA.
Edit I should probably add this is just one of a number of System packages for which I am getting this warning. Others include:
System.Diagnostics.DiagnosticsSource
System.Memory.Data
Edit 2 In case it is relevant, the root project is an Azure Cloud Service "Classic" worker role built using the Azure SDK which is why (regrettably) I can't just target .Net5 to try and work around this.
Edit 3 The conflicts appear to be resolved when adding local dependencies at a matching version but I would still like to understand where the original conflict is coming from and what the warning is trying to tell me. I think it is implying that the 472 framework depends on a different version of those packages/dlls but if so it's unclear what the appropriate resolution should be.

Generate Objective-C Framework from .NET Standard Project using Embeddinator 4000 on Windows

I have a current Xcode iPhone project that I would like to switch over to Xamarin so that I can support iOS and Android with a single code base. However, in the short term I don't have the time to replace the Xcode project with a Xamarin forms version. Therefore, I have come up with a plan to build the core logic into a Xamarin solution in VS20017. I would then use Embeddinator-4000 to generate a .framework file which I could use from my Xcode project. In this way I can maintain the current Xcode UI project while I work on a full Xamarin replacement.
I was hoping to develop on a Windows machine, as this is what I'm most used to, but I can't seem to get embeddinator to work.
I've tried to get it to work with a Xamarin.iOS project, .NET Standard 2.0 and .NET Framework 4.6.2. Each fails with a dependency error, given below:
Xamarin - Can't find the assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e', referenced by 'Embed.Xamarin, Version=1.0.7015.35480, Culture=neutral, PublicKeyToken=null'
.NET Standard - Can't find the assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51', referenced by 'Embed.Standard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
.NET Framework - Can't find the assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089', referenced by 'Embed.NetFX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Embedded.NetFX
I have two questions
Am I using a workable approach to migrate my Xcode project over to Xamarin or is there some other option, of which, I'm not aware of? Maybe a conversion tool?
If this approach is workable, what do I need to do to get Embeddinator to work on a windows machine? Is it even possible?

How to diagnose warning MSB3277: Found conflicts between different versions of the same dependent assembly that could not be resolved

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.

Visual Studio Team Services Build Error on "System.Web.http" version

I have few projects in my solution referring Syste.Web.Http and Formatting binary. Things are fine few days back but last week my Team Services build started failing without any changed made on ref: and it gives me below error
Assembly 'Microsoft.CloudOA.Wizard' with identity 'Microsoft.CloudOA.Wizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Http' with identity 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
However, the same project is building fine in locally. I tried looking into all projects and made sure none of my project is using 4.0.0. But no luck. Can some one please help me to get rid of this issue? Thanks in advance.
Make sure that you check all bin folders. I mean it can be changed in bin folder, but reference in project can be still to 4.0.0.0.
Try running "Update-package" command for all your projects from "VS\Tools\Nuget Package Manager\Package Manager Console" to update the referenced packages to the latest version.

Categories

Resources