How to suppress Tasks.Task different PublicKeyToken error - c#

I noticed I get one line of code underlined. If I understand correctly, the error means that I have two different versions of some library in my solution. However the error doesn't stop the solution from compiling and everything works like it's supposed to work. What is the reason of Visual Studio underlining this line of code? How can I stop this from happening? Where to look for some incoherence?
The exact error is:
Cannot convert instance argument type 'System.Threading.Tasks.Task [mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]' to 'System.Threading.Tasks.Task [System.Threading.Tasks, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]'
I use Nito.AsyncEx v3.0.1 package in a WebApi (v5.2.3 I think) solution which targets .NET Framework 4.5.1. Let me know if you need any more information.

I removed reference to System.Runtime and it seems it fixed the issue. I followed the advices from below question kind of blindly, but it seems it was the same issue.
Problems with references to TPL Dataflow and TPL in VS 2012 RC

Related

.Net Framework You must add a reference to assembly mscorlib, Version=4.0.0.0

After updating and including some NuGet packages, I now get many compile errors similar to:
The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
I looked at You must add a reference to assembly mscorlib, version=4.0.0 but I'm not running .Net core - this is an ASP.NET MVC, .Net Framework 4.7.2 Project.
There is no project.json to update. I already included the Microsoft.NETCore.Portable.Compatibility NuGet package to no effect.
What is causing this, and how can I fix it?
Right-Click on your project and click Clean Solution in Visual Studio, and then try building it again. Solves the problem most of the time for me.
Or else, in case you copy-pasted a class from somewhere else, try creating a new class in your project and instead, copy-paste the code within the other class instead of just copying the class itself.
I also faced the same issue, I got this when I was trying to install EntityFramework.
Code Clean-Up worked for me. Go to analyze and then try to run code cleanup using both profiles.
For completeness's sake, I'll include the fix that actually worked for me as an answer.
Just delete the repo, re-clone, and try again.

MSB3258: mscorlib 4.0.0.0 and 2.0.0.0

So I'm trying to compile a project on VS 2017, and I'm getting this:
warning MSB3258: The primary reference "someLib.dll" could not be resolved because it has an indirect dependency on the .NET Framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.
After that, I have errors relating to this dll (for example, a type or namespace not being in the namespace), but when I double click the error it disappears, along with the red squiggly line in the code, hinting at the fact that it's not the actual problem.
Nothing I tried is working: all of the projects are on 3.5, I removed and re-added all of my references, and it doesn't happen in any other computer except my own. I also tried removing mscorlib from the GAC (however dumb that may be), but of course it won't let me.
I saw something that may be relevant:
https://developercommunity.visualstudio.com/content/problem/230636/assemblydependency-now-misidentifying-indirect-dep.html
Other than removing and reinstalling VS, not sure what to do.
If anyone has any idea, I'd be glad to try it.
It was a weird reference to a version of Interop.Shell32.dll called just "Shell32.dll". Don't know where it came from.
If anyone else has this issue: remove each dependency one at a time and compile. Even the Microsoft ones.
Answer from comments:
Check the libraries someLib.dll references. Maybe they contain a reference to mscorlib.dll 4.0.0.0.
Hint: add official Microsoft libraries via Via Add Reference > "Assemblies tab" (on the left, don't know if tab is correctly named). Don't add them by browsing for them.

System.IO.FileLoadException on System.ServiceModel.Primitives

I am currently working on a Xamarin project, and I required something that Xamarin on it's own doesn't support, so I looked for solutions. After messing around with some NuGets, my project ended up with a bunch of weird and unexplainable compile errors, popping up and disappearing randomly.
Eventually I realized that I removed a NuGet from the shared project, but not the UWP one. After removing it from UWP, the program compiles and runs. But seems that there is some more damage done...
However, when I try to call a method of a class defined in a different file, it throws a System.IO.FileLoadException, which it previously wasn't doing. The complete Exception message is:
System.IO.FileLoadException: 'Could not load file or assembly 'System.ServiceModel.Primitives, Version=4.5.0.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'
After a bit of digging, it concluded that it is probably caused by a missing nugget, which I must've deleted by a mistake. So I installed a 4.5.3 version. Didn't help. Restarted Visual Studio, no effect.
I can't install any earlier versions, as it is considered being a downgrade by something. Any clues how to deal with this?
I had the same problem in my UWP project.
My solution was to remove checking if the exception is a FaultException. It seems like FaultException is not supported. After removing the check my method works fine, I could step in etc. Hopefully this helps you too and solves your problem.
My case it solved by update the System.ServiceModel.Primitives for .NET Standard to 4.4.4. version as mentioned below,
https://github.com/dotnet/wcf/issues/3088#issuecomment-411603736

Pechkin lib throws a TypeLoadException

I've tried many examples that use Pechkin and Pechkin.Synchronized but can't get it to run, because all the times, I get the following error.
An unhandled exception of type 'System.TypeLoadException' occurred in mscorlib.dll
Additional information: Could not load type 'Pechkin.GlobalConfig' from assembly 'Pechkin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
I'm using x64 Windows 7 Home Basic with VS2012 Express for Desktop and the csproj is configured to build for x86 target and installed Pechkin and Pechkin.Synchronized from using nuget PM.
The last code I tried was from here
It has been a while since you asked this question and you've already fixed your issue, but maybe it'll help someone else.
You should probably try implementing TuesPechkin instead. This is a fork of Pechkin solving many issues (Pechkin issues) and using the latest version of WKHTMLTOPDF. The developer is quite active and will probably solve any bug you may find.
I think the problem was the name of my C# Console project, it was Pechkin. When I changed it to PechkinTest, System.TypeLoadException did not arise.
Anyways, thanks.
I also got the same problem and i changed my project name from Pechkin to some other name and the problem solved !

NDjango throws TypeLoadException

I'm just trying to get started with NDjango but am having issues running a basic test app. When running the page in either debug or release the following exception is thrown:
Could not load type 'Microsoft.FSharp.Core.CompilerMessageAttribute' from assembly 'FSharp.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
This is thrown when the NDjangoHandle is created in the HttpApplication ctor. The fsharp assemblies are definitely all there in the gac (and they seem to be distributed with NDjango too) so I'm a bit confused about this one. Googling this turns up zip.
I'm using NDjango 0.9.7.0 for .NET 4.0 in vis studio 2010
Cheers
Did you install FSharpPowerPack? I am not sure if it was stated clear enough in the installation package but it is required and it does not come with the standard installation.
Also - by any chance do you have a side by side installation of VS2010/VS2008? The FSharp installation package has a bug which can cause similar problems
Let me know if you need further help. You can communicate with us directly through bug tracker and/or mailing list

Categories

Resources