MEF composition failing to find System.Data.Edm 5.6 - c#

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\".

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.

Dependency error (System.Net.Http) when using Azure deployment options - works when publishing in Visual Studio

I have a very weird situation I hope someone can help with!
I have a normal ASP.NET MVC website. I've set up "Deployment Options" to push to a domain on every Develop commit. However, this has started giving the dependency error:
Could not load file or assembly 'System.Net.Http' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Now, I thought this was some caching since solution worked locally. So I have been publishing the app inside Visual Studio a couple of times (with option of deleting all remote files), and then the solution works.
However, after doing this, and I go back to a normal commit with Deployment Options, I go back to the same error:
From your description it seems like it has deployed successfully in past.
Have you upgraded project recently? If yes, look at this thread Strange issue with System.Net.Http 4.2.0.0 not found
Also, check if you are referencing DLL from NuGet and not GAC.
First thing that comes to mind is that you added a new DLL in your solution that depends on another version of System.Net.Http assembly. If you know that you added a new DLL, check for its assembly dependency.
Another solution might be to manually specify the version of the assembly in code. And select SpecificVersion. (but I'm guessing it's the first thing that causes the issue).
I have came across similar issue once. There should be a mismatch of the versions between System.Net.Http package.
Try verifying the version of System.Net.Http for the entire solution and refer the same version in all the projects.
This happens if a package is referenced in a project and different version of the same package is referenced in another project. Here, this error occurs when there is a reference between these two projects.

One web application with two dlls. One dll is dependent upon the other. Why do I have to update both DLLs?

I have a web application that has two referenced assemblies in the form of DLLs. Lets call the DLLs Primary.dll and Secondary.dll. The Secondary.dll is dependent upon Primary.dll.
I need to add a feature to Primary.dll for use within the web application. This requires a new version. This new feature is not required by Secondary.dll. There are no breaking changes for Secondary.dll.
Now when a bit of code in Secondary.dll is triggered, I get the following error:
"Could not load file or assembly 'Primary.dll' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. "
Secondary.dll is looking for the specific version of Primary.dll
Is this solved simply by making the SpecificVersion="false" value in the Secondary.dll project file?
If not, I've thought of keeping the older version of Primary.dll in the GAC, this way Secondary.dll would find it there. But would like to avoid this if possible.
So now I'm stuck with having to rebuild and re-version Secondary.dll, with a reference to the updated Primary.dll, every time I make a change to Primary.dll for use by the web application.
Is there way to make it so I don't have to update Secondary.dll's reference to the new version of Primary.dll?
If changes are really not breaking, try this way:
Check assembly attributes of your Primary.dll and get rid of signing and auto-generated assembly version (change 1.0.0.* to 1.0.0.0).
If it doesn't help, open Secondary and Primary with ILSPY utility and check what the exact the reference to the Primary.dll, and compare it to the actual full assembly name of Primary.dll. Also check references to your other dll, that could be referenced in both Primary and Secondary.
If it doesn't help, possible you have several files of Primary.dll assembly with different metadata and assembly loader loads the wrong one. Just find and delete wrong files or use Fusion Log Viewer utility to explore assembly binding. Maybe, this can help.
To make the investigation more simple, use simple almost empty ConsoleApplication with reference to Secondary.dll to play instead of web application.

Finding where an old NHibernate DLL is referenced

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.

"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