I have a class that implements IXMLSerializable in a .NET Standard Library, but I can't compile the library because it's referencing IXMLSerializable in two places. The output is as follows:
error CS0433: The type 'IXmlSerializable' exists in both
'System.Xml.ReaderWriter, Version=4.1.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' and 'System.Xml.XmlSerializer,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
I only see one reference under the dependencies though (System.Xml.XmlSerializer), which I need for the XML attributes. This is my first crack at a .Net Standard Library, so is there something I'm missing here?
Try upgrading your reference to System.Xml.XmlSerializer to version 4.1.0.0.
The error message says that you have two references to the library, but are using different versions. System.Xml.ReaderWriter is using a newer version than your project is, so you need to get that version.
You could also try removing your reference to System.Xml.XmlSerializer or switching it to an older version.
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 have recently made the decision to try and re-standardise my older style PCL's from the (apparently archaic) old approach of portable-net451+win81+wpa81 to now netstandard1.x. I took this decision as Xamarin Forms on my Mac was no longer recognising one of my libraries as a NuGet package.
Anyway, having started this conversion I have entered a world of unknown pain in the sense that it isn't a very automatic process. I'm now at the stage where I think I've converted my PCL's to net standard libraries but now I'm trying to reference these standards within a 'normal' windows console app I get odd errors.
Primarily my errors are thus:
Error CS0012: The type System.Linq.IQueryable 1<TItem> is defined in an assembly that is not referenced. Consider adding a reference to assembly System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (CS0012)
Error CS0012: The type System.Collections.IEnumerable is defined in an assembly that is not referenced. Consider adding a reference to assembly System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (CS0012) (Redbridge.Console)
Now given that my project is referencing one of my net standard libraries and this error originates from me using a class that requires packages System.Linq.Queryable and System.Linq to be added specifically to my net standard library I can't help but wonder how I'm meant to make this work in my console app library. I note that the versions are .20 rather than the standard .0 so what do I do to make this work?
I've tried the obvious (referencing the above packages in my console app as suggested by the compiler) but to no effect. Does anyone have any advice? Do I need to add a project.json file for example to my console app so that I can indicate that .NET standard should be used or something?
I've read quite a bit on the .NET standard and like most find it confusing as to what I'm expected to do.
I tried to migrate a MvvmCross project to Unified API and got stuck at MvvmCross libraries, as soon as I add them, it fails to compile.
To recreate the issue I simply created a new Unified API empty project and added MvvmCross 3.5 NuGet package. Tried to compile and got these errors:
Setup.cs(8,23): error CS0012: The type 'System.Object' is defined in an assembly that is not referenced. Consider adding a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
DebugTrace.cs(9,27): error CS0012: The type 'System.Enum' is defined in an assembly that is not referenced. Consider adding a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
I'm using Xamarin Studio 5.8 for Mac with Xamarin.iOS 8.8.
Shouldn't this work out-of-the-box? Am I missing something?
EDIT: Created a new solution from scratch and it works as expected, so I guess it should be something related to the solution file.
It seems that deleting bin and obj folders and a Xamarin Studio restart did the trick. Now everything is worked as expected.
If I try to use the JsonServiceClient of Servicestack I always get the following Exception:
Could not load file or assembly 'ServiceStack.Text, Version=4.0.14.0,
Culture=neutral, PublicKeyToken=null' or one of its dependencies.
System cannot find the file specified.":"ServiceStack.Text,
Version=4.0.14.0, Culture=neutral, PublicKeyToken=null
The project runs with .net 4.5 and the Servicestack Version 4.0.15.0. That ist the weirdest thing, because I never had 4.0.14.0 as a reference. I only have a reference to Servicestack.Text 4.0.15.0 and all the other ServiceStack libs in 4.0.15.0
Before I had the same Problem with 3.9.66.0 expecting 3.9.63. But I upgraded via NuGet hoping to solve the Problem but it didn't work.
I just noticed in my Outputfolder that Servicestack.Text was missing. Now I use a direct call to a class in Servicestack.Text and the compiler isn't optimising Servicestack.Text out.
I have a library of html helpers as a separate project. Right now it references system.web.mvc of version 4.
If I try to use this library in a project that uses mvc3 it throws an error when a helper is attempted to be used:
Compiler Error Message: CS1705: Assembly 'MyHtmlHelpers, Version=3.7.4.0, Culture=neutral, PublicKeyToken=null' uses 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
I understand that I need to build my helpers project with system.web.mvc of version 3 referenced in order for it to be compatible with mvc3 project. I do not want to have two projects with the same code with just the difference of system.web.mvc referenced.
Question is in the title.
Any help is appreciated.
I do not want to have two projects with the same code with just the
difference of system.web.mvc referenced.
You don't necessarily need to physically duplicate the source code. You could just have another .csproj for your class library which will add the source code as Linked Files and only replace the version of the System.Web.Mvc reference in the .csproj.
Take a look at how standard projects such as JSON.NET have their source code organized. They support multiple versions of .NET from 2.0 up to 4.0 and yet the source code is the same. It's the project files that are doing the job.