Finding where an old NHibernate DLL is referenced - c#

I'm working on a ASP.NET MVC C# project and I'm getting the following error when launching the web app:
Could not load file or assembly 'NHibernate, Version=2.1.0.1001, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Based on the error and some googling it seems clear that there is something referencing a NHibernate dll version 2.1.0.1001. However, our project is using NHibernate version 2.1.2.4000 (old, I know). I've searched the entire solution for any references to that version of NHibernate and cannot find one. I'm assuming that another DLL that we're using is referencing it, but I don't know the best place to start to figure out which.
Am I on target with what the issue likely is? Any (hopefully free) dependency tools that anyone can recommend?

I think you are on-target with the basic issue. Consider a stale output file from your solution too. A rebuild (i.e. clean and build) should cover that possibility.
A good free tool for checking references in assemblies you reference is Telerik JustDecompile.
Also, Fuslogvw.exe (Assembly Binding Log Viewer) may shed some light on the load error.

Related

How do i add dependencies to ASPX forms project? (nuget already tried)

I have worked with asp forms long time ago, now i must create a simple web interface, which uses powershell library.
[Nuget URI][1]https://www.nuget.org/packages/System.Management.Automation/
But seems impossible.
using System.Management.Automation; <-- doesn't work any place.
Already tried installing the usual way (via cli and giu), copying the library to \bin folder and many other ways.
I often get the error:
Severity Code Description Project File Line Suppression State
Error Could not load file or assembly 'System.Management.Automation, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)
I am trying Web Forms because of simplicity, hope i am missing a simple thing.
Any help will be appreciated.
It was a version incompatibility, as mason pointed out on 1st post comments. Use the OS library located on C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Management.Automation\v4.x.x.x.x__xxxxxxxxxxxxxx
.net Framework aspx is getting complex, don't be fooled on other kind of projects or scripts where you can use any binary you can find.
I used "\sn.exe -Vr yourDll.dll", and "sn.exe -Vl" to register and check the nuget library to GAC but, i got another error:
Could not load file or assembly 'System.Runtime.Extensions
Seems i must use the actual OS library, otherwise it won't work.
Also tried creating custom libraries and workes (myClass1 worked), no GAC registry needed.
Also tried downloading mysql official library, which registers, and worked.
Anyways, hope helps to someone.

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!

MEF composition failing to find System.Data.Edm 5.6

I'm trying to compose my app but MEF keeps spitting me the error:
Could not load file or assembly 'Microsoft.Data.Edm, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
And now i'm stucked... i've tried to replicate the problem in a small scale kind of project, but i can't! which means im doing something wrong here... i need help... i'm quite lost and frustrated and i dont know what kind of info you would need in advance... so, ask for whatever you need!
The basic architecture is:
4 projects, being one WebApi (where i`m composing), one library (where all interfaces are located), one Domain and one DataAccessLayer...
WebApi, Domain and DataAccessLayer projects reference the "Library" (they don't reference each other... very loosely coupled I think)
DataAccessLayer has Azure.Storage NuGet package installed because it handles data in azure (cache and storage)... I also installed it on WebApi because i was unable to "move" the required dlls efficiently. (at run time all dlls, including Data.EDM, are in the bin folder, i've checked)
If any extra info is necessary pls ask!
Those MEF errors can be tricky... usually it's very subtle stuff that trips it up. Try the following:
Check if the projects have the CopyLocal value to True
Check if the NuGet Packages all have the same version.
[Symptom]
If you started having this issue without introducing new dependencies, it is likely that your temporary asp.net folder has lost integrity.
[Solution]
Try deleting "%LOCALAPPDATA%\Temp\Temporary ASP.NET Files\".

Could not load file or assembly Not exact version

I'm using MigratorDotNet to do migrations. I give it a string to my Assembly My_Assembly which is built on Sharp Arch v2. Sharp Arch v2 is built on Fluent Nhibernate 1.3.0.727.
My project is using 1.3.0.737
I'm getting the following error when MigratorDotNet calls Assembly.GetExportedTypes:
System.IO.FileNotFoundException: Could not load file or assembly 'FluentNHibernate, Version=1.3.0.727, Culture=neutral, PublicKeyToken=8aa435e3cb308880' or one of its dependencies. The system cannot find the file specified.
I'm familiar with BindingRedirects but would prefer to not change source code for MigratorDotNet (it does't pull in external config).
Is there a way I can force the new version and prevent the FileNotfoundException?
P.S. I know there a lot of similar-phrased questions but those are usually resolved by binding redirects, ensuring Copy Local = true, adding assemblies to the GAC, etc. I think this question is more generic.
I hate to say it, but I think you are going to have to live with binding redirects. I've not found a way to do what you are asking yet myself, but would love to see if there is one.

"Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Validation" exception

I am currently getting the following exception while trying to use the Enterprise Library Validation Application Block:
An error occurred creating the configuration section handler for validation: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Validation, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) (C:\Documents and Settings\My Documents\Visual Studio 2008\Projects\Testers\TestProject\web.config line 12)
I know what the exception is trying to tell me, but I can't figure out how to fix it. I have only ever installed one version of the Enterprise Library, and this is it (4.1.0.0), so I don't see how it could be finding the wrong version, so I imagine it is then a dependency problem. I have included the "Common", "Validation" and "ObjectBuilder2" DLLs from the Enterprise Library 4.1 as references in the project, so I'm not sure what else I'm missing. The documentation certainly seems to indicate this is all I need.
Is there any way to track down what the dependency problem is?
If it helps, I am trying to use the Enterprise Library Configuration Tool to create a Validation Application Block rule set for validation of data in an Entity Framework entity. I am using ASP.NET MVC in Visual Studio 2008.
Thanks for any assistance/direction you can provide,
Chris
Turn on Fusion logging and see what assembly is being bound at runtime.
Hanselman had a post recently that should be helpful in enabling logging and examining the output.
http://www.hanselman.com/blog/CommentView.aspx?guid=3654c8f3-c5c3-4dee-a01f-c9a8da3ef2fa
Another important distinction to make is that references that are added to the project are compile-time references and don't affect the way that code is bound at runtime other than to specify a strong name if a strongly named assembly was used. In order to find out what is happening at runtime you need to look at the binding logs. The log should show you all of the attempts that the runtime makes at locating the assembly. If the assembly is not in the bin directory along with your exectuable, it is most likely looking in the GAC and finding a version that it does not expect.
Note that the compiler DOES NOT use the GAC when referencing assemblies. So most probably you have a different version used as a reference in the project than you have installed in the GAC.
Also, it is very easy to find out what version you have installed in the GAC by looking in C:\Windows\assembly using Windows Explorer. The version that is specified in your error message will be the version that was referenced during compilation. If these versions don't match this could be your problem, assuming that Fusion is indeed looking in the GAC (which will be evident by looking in the Fusion log).

Categories

Resources