FileLoadException: The located assembly's manifest definition does not match the assembly - c#

I downloaded a NuGet package for a project (Episerver). I'm trying to replace one specific dll with one of my one of my own implementation, with same name, same namespace, etc... by deleting the dll downloaded from Nuget and loading mine as a reference.
Everything compiles fine, but when trying to execute it, I get the following error:
Could not load file or assembly 'Mediachase.Commerce.Website, Version=7.10.1.169, Culture=neutral, PublicKeyToken=6e58b501b34abce3' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Does anyone have a clue on how I can solve this issue? Because I've been smashing my head quite some time against that problem, checked endless forums, and couldn't find any solution that works for me.
Thanks!

That won't work - you have to rebuild assemblies referencing the one you've replaced as well. You can try to use reflector to make c# code from those assemblies referencing your dll and rebuild those assemblies.

Related

How to resolve "The located assembly's manifest definition does not match the assembly reference." error?

I downloaded source code for pdfiumviewer from git hub. I made changes to one of the projects in that solution.Then I added that project to my application and added reference of that project to one my application's project.I had to uncheck the Signing option for the PDfiumViewer project, as some of the dll in that project are unsigned.I am able to build the application successfully.But at run time when I create an object of one of the class of PDfiumviewer project.It gives me the following error:
Could not load file or assembly 'PdfiumViewer, Version=2.11.0.0,
Culture=neutral, PublicKeyToken=null' or one of its dependencies. The
located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040)
The version number of the assembly is correct.So, why am I getting this error?
The problem was that I had added reference of old unmodifed PdfiumViewer dll to another project.Hence, there was conflict between the two dlls (old and customized) at runtime.I removed the old dll reference and it worked.
Ive also encountered this issue, my scenario was thou that I had to add a reference from another solution into my project removing the reference was not an option - what worked for me was reinstall SQLclient from nuget package managerer on both solution. Hopes it helo someone else
The issue here is that you have a library that references v2.11.0.0 of the Pdfium library. This library could be an assembly that you built earlier, or another assembly that came from Pdfium that references this version of the library. When you built your version of the library you probably didn't use this same version number, and it wouldn't have been strong named correctly. To fix this, you can add an assembly binding redirect in your applications configuration file to redirect the offending library to your custom built one.
I wrote a program to fix this issue automatically: https://github.com/BackTrak/DependencyFixup/releases/tag/1.0.0.0
I know this question is old, but hopefully this helps out others!

All files containing assembly references

Trying to hunt down a way to fix this error without building a new solution.
I have removed and re-added the Json reference with no luck inside VS.
Could not load file or assembly 'Newtonsoft.Json (1)' or one of its
dependencies. The located assembly's manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)
It looks like it somehow was referenced twice since it has (1) in it.
In my experience, that sort of error tends to happen if the assembly is renamed. The (1) looks like it may be the case.
I would try removing the reference (all instances of this particular reference) and either readding the original file, or getting it again from NuGet. If NuGet is not an option, check the filename of the physical file you're referencing, and make sure there's no (1) on the end of that.
Found the file in the bin folder and just deleted it. Works now.

Assembly's definition does not match

Error 2 Could not load file or assembly
'CrystalDecisions.Enterprise.Framework, Version=10.2.3600.0,
Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its
dependencies. The located assembly's manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)
Can anyone tell how to correct this error?
I tried to delete the files from the bin folder and I even tried downloading a new dll file and added reference to it. Still it didnt work out.
The solution was pretty simple. Just delete the assembly and associated files from my projects bin folder and then choose Add Reference to add the latest version back in.
This can be due to your project file referring to one version while the version copied into the bin folder is a different one. So when the app runs it's trying to load the version the project file references, but finds only the one copied into the bin folder.
Was the library added through Nuget? It could be that the version in the referenced in packages.config and used in the build doesn't match the version number in the project file.

log4net manifest definition mismatch

I'm getting this issue while running test client
Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I found many solutions like adding both versions, or enable logging in registry but nothing worked for me. I'm just stuck over here.
Anyone has any idea regarding this then please help me out. Any kind of help will be appreciated.
I expect you have a reference mismatch between two different assemblies with one expecting version 1.2.10.0 of log4net and another some other version. One version of the log4net assembly is copied to your output directory when your solution is built and then when your program is launched the .exe loader is then complaining because it isn't able to load the version of particular assembly (or .exe) is expecting. Upgrading / downgrading your assemblies to use the same version of log4net should solve the problem.

Strange error every second build Facebook SDK C#

I keep getting this error:
Could not load file or assembly 'Facebook, Version=5.4.1.0, Culture=neutral, PublicKeyToken=58cb4f2111d1e6de' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Can anyone help me?
I faced a similar problem once when there were two different assembly versions available and when the assemblies were copied across projects with some inconsistently set assembly references. The versions got mixed up and the error appeared.
But take a look a this and links provided there, it should give you some suggestions or ideas:
The located assembly's manifest definition does not match the assembly reference

Categories

Resources