Exception from HRESULT: 0x80131040 - c#

Warning 1 D:\MyPath\SomeAscx.cs: ASP.NET runtime error:
Could not load file or assembly 'HtmlAgilityPack,
Version=1.4.0.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a'
or one of its dependencies. The located assembly's manifest definition
does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I have removed the reference and am not using it in code why would this still be an issue. I have tried cleaning solution, rebuilding, open and closing solution but still no success. Has anyone come across this issue before?

Even if you removed direct references, something else might still require that dll.
I'd suggest:
Recycle your IIS application pool (or run IISRESET from the command prompt to reset the entire web server)
turn on FusLog and check who is the real "offender"

This can happen if your project name conflicts with a nuget package you referenced. I wasted about 30 minutes before I realized what is going on.
I was doing a ReactJS tutorial, so I created a project called React, and then later I imported ReactJS.NET from nuget.
When I hit build, Visual Studio will build React.dll in bin folder since my project name is React, this dll overwrites the React.dll imported by nuget package ReactJS.NET
So my project blew up... and I wasted 30 minutes scratching my head.

Related

Error NETSDK1060: Error reading assets file: Could not load file or assembly

I created a .core console application and without adding any nuget packages or even one line of code, I did a build on it and got two errors (Visual Studio 19 16.8)
Error NETSDK1060 Error reading assets file: Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified. ABC C:\Program Files\dotnet\sdk\5.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets
the lines in question in the Microsoft.PackageDependencyResolution.targets:
ProjectAssetsFile="$(ProjectAssetsFile)"
After fighting this for hours, I went ahead and uninstalled Visual Studio 2019 and even used InstallCleanup.exe in hopes of scrubbing any settings I may have messed up.
After reinstalling Visual Studio clean, I created a .Core console application and built it -- same error.
What is going on? With this line I am assumming that its in my projects project.assets.json file ... but I have nothing about Newtonsoft.Json, Version=9.0.0.0
'''$(MSBuildProjectExtensionsPath)/project.assets.json'''
It is obviously loading some deeply rooted and hidden project.assets.json file but how do I find where this is? I have been on this issue for over 9 hours.
Any help would be appreciated.
Thank you.
EDITS:
This is only happening with a . Core console application. a standard .Net framework console application has no problems.
Also, if I add a random nuget package, the top level package under dependecies has a yellow asterick, although the .dll under that is pointing at a valid DLL

DLL looking for wrong version

I have developed a class library (dll) that uses WinSCPnet.dll in Visual Studio 2015. While troubleshooting why it was looking for the wrong dll, I added the Nuget for it, getting the most recent version. The version we are using is actually a few before that, so I uninstalled the latest (using Nuget) and installed the version I want. Now, when it runs, it is looking for the newest version.
System.IO.FileLoadException: Could not load file or assembly
'WinSCPnet, Version=1.6.5.9925, Culture=neutral,
PublicKeyToken=2271ec4a3c56d0bf' or one of its dependencies. The
located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040)
I have tried searching the registry, gacutil /u (which ran successfully and removed the dll but I still get this message), cleaned the project and rebuilt, deleted everything in bin and obj and rebuilt - what am I missing?
Thanks!
Try this :
Unload your project , right click, edit .csproj file .. find your reference , it's gone be something like this <Reference Include="WinSCPnet, Version=1.6.5.9925 .../>", edit that create open close Reference tag <Reference></Reference>
Inside put <HintPath>path to your dll file here</HintPath>
Hope this helps!?

Assembly error after splitting solution into different projects

So, I had a ASP.NET MVC application, but everything was in 1 project. (ugh)
I decided to get a little closer to how it's done in the field, and split up into different projects in one solution.
After doing so, I spent some time adding all the needed assemblies to my new DataAccess project, adding it as a dependency to the other project etc. To have it not run and throw the error:
Could not load file or assembly 'MySql.Data.Entity.EF6, Version=6.9.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
So clearly something was wrong with the MySql.Data.Entity.EF6 reference.
I spent hours searching for a solution, from changing the versions in my web.config to completely deinstall and reinstall the dependency, but no matter what I did, the error was here to stay.
If you've tried what I've tried (no matter the reference you're stuck with) It might be a good idea to check if it's been referenced in any other project in your solution.
If so, delete the reference from the other project (not the DataAccess project). And make sure you have the right versions in your web.config. You can check the versions via properties in VS.
When I did that, everything suddenly worked just fine.

Could not load file or assembly occurs after few days

I took over a project recently and it's using the NopCommerence package. When I load up the package in Visual Studio, it works fine, I have no troubles in VS, when I push live, everything is fine too, all works, but as soon as a few days sometimes even hours have passed, I get this error message:
Could not load file or assembly 'NPOI, Version=2.0.6.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
To solve this, I have to clean, rebuild and build the project and release a new set of files, my question is why does it randomly just fall over after so much time? I tried resetting the server, deleting temporary files but no luck.
Been doing this for weeks now and I can't find a solution.
This seems to be an issue where your .NET assembler is looking for an assembly of a specific version and instead of finding that, it is finding the assembly of that same thing, but of a different version.
It means that it wont work until both the files, i.e the actual file at the location and the reference in your configuration are same.
Check your config and then check on the actual file. If its of older or newer version, then replace it with the version that is actually required.
Here are a few links for your reference.
Assembly version mismatch
Resolving assembly conflicts
Hope this helps.

nopCommerce assembly dont find dll reference

Im having some serous issues with a .dll not being found in Nop.Core.dll (i think)
the dll message the PluginManager.cs writes in the output in VS12 is as follows:
Could not load file or assembly 'Telerik.Web.Mvc, Version=2012.2.607.340, Culture=neutral, PublicKeyToken=29ac1a93ec063d92' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Ive added the right version of Telerik.Web.Mvc to the Nop.Core lib and built a new .dll but the issue still remains.
Ive also checked for cached .dlls in th GAC but nothing.
The issue occured after a restart of VS12 so there´s smt weird going on here. Ive tried disabling/enabeling auto update nuget on build (as i thought that it might be fetching some new dlls that might create a conflict) but nothing.
I do see that the Solution is running .net 4.5 but the Telerik.Web.Mvc.dll target framework is :
TargetFramework(".NETFramework,Version=v4.0", FrameworkDisplayName=".NET Framework 4")].
Can this cause some dll´s to not find Telerik.Web.Mvc.dll?
As im new to nopCommerce im kinda lost at this point. What am i doing wrong here? =)
/seb
Edit:
Make sure you have non-corrupted Telerik.Web.Mvc.dll in your bin folder (download one that comes with nopcommerce and overwrite it to be sure)
This issue may be caused by a plugin that has wrong reference. If you have any custom/old plugins try removing them or readd their reference and recompile.
Current version in 3.10 is 2013.2.611.340 while you have reference to 2012.2.607.340

Categories