Could not load file or assembly 'EntityFramework, Version=4.3.1.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its
dependencies. The located assembly's manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)
I only get this error when I add this code into my project:
private IUserRepository repository;
public SearchController(IUserRepository repo)
{
repository = repo;
}
I suppose that makes sense as I'm using EntityFramework for this. I'm just now sure how to fix this bug.
I've looked at this link: http://msdn.microsoft.com/en-us/library/e74a18c4.aspx
Though I'm not sure how to use this program? (It's always blank).
I think that this bug may have something to do with the fact that my database is hosted by dotnet-host.com and that there's some local references that break when it interacts with the database online.
What the error is telling you is that your project referenced a different version of EntityFramework.dll than it found at runtime.
Check which version of EntityFramework.dll did you reference in your project (update your question).
Make sure you copy all the relevant dll and *.manifest into application's bin folder.
Since It's an external host, You might need to install the EntityFramework through WebMatrix Package Manager. If you do, you can follow this tutorial.
Just make sure to install the same version of EntityFramework on your host site that you use for development, or
change your assembly reference to Specific Version = false on EntityFramework dlls (Note I'm not sure if it will work, because I always try to develop and deploy using the same versions, so maybe somebody can confirm?).
Related
Tying to build a freshly cloned project, when i build i get this error
Could not load file or assembly 'Microsoft.Configuration.ConfigurationBuilders.Azure, Version=1.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)
Things I've tried
Removing the reference and adding back in
changing build properties from debug to release
disabling strong name verification via command line using the command "sn -Vr
Microsoft.Configuration.ConfigurationBuilders.Azure.dll"
i've tried updating the reference to latest / previous versions
Everything I try and nothing seems to work, any other ideas?
In app.config or Web.config, delete the following:
, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
download this nuget package and this will work for you.
.NET Framework:
For me the issue was that I had to change the Version=1.0.0.0 in my web.config to match what was loaded and referenced in the web application references. Right click [Microsoft.Configuration.ConfigurationBuilders.Azure] and go to properties and you'll see the version at the bottom. For me it was Version=2.0.0.0.
My project builds for my teammates, but not for me.
Project:
Errors:
I deleted reference to mscorlib fake, recreated Fake for System, but got the same error.
If I try to add reference to mscorlib, I get message:
A reference to
'C:\Windows\Microsoft.NET\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'
could not be added. This component is already automatically referenced
by the build system.
I tried to add <Reference Include="mscorlib" /> to the project file, but this did not resolve the issue.
I use VS 2017.
Will appreciate any clue.
Thank you #Abhitej, for the answer. It resolved the issue. In addition to switching to higher version of framework I added tags like <Remove FullName="System.Security.Cryptography.CryptoStream"/> for each failing class to both ShimGeneration and StubGeneration in .fakes file.
In most cases like this one its tied to the version of .Net Framework installed on the box. As long as your test project targets the highest version of the Framework on your box, this should work out. Also when dealing with System* namespace please be sure to only generate fakes for types you need excluding others. That should help Fakes deal with API changes over versions and resolve any build errors you might be seeing because of this.
-Abhitej.
The error:
Failed to add reference. The package 'SimpleInjector.Integration.WebApi.WebHost.QuickStart' tried to add a framework reference to 'Microsoft.Web.Infrastructure' which was not found in the GAC. This is possibly a bug in the package. Please contact the package owners for assistance.
Cannot find assembly 'Microsoft.Web.Infrastructure'.
First of all. Why the error when I have the dll and reference to it in my project?
Second. How do I fix this?
Obviously I've tried to add the assembly to my GAC with various guides from Mircosoft. None of them makes sense imo.
https://learn.microsoft.com/en-us/dotnet/framework/app-domains/how-to-install-an-assembly-into-the-gac
This results in "Failure adding assembly to the cache: The system cannot find the file specified." I guess that's because it's not a strongly typed name with a key pair or what ever. So I looked into this https://learn.microsoft.com/en-us/dotnet/framework/app-domains/how-to-sign-an-assembly-with-a-strong-name
which makes absolutely no sense. It says:
"In the Choose a strong name key file box, choose , and then navigate to the key file. To create a new key file, choose and enter its name in the Create Strong Name Key dialog box."
What key file? Create a new and just come up with a random name? Wtf? How is that related to a specific assembly?
I faced a similar issue with error "Unable to uninstall 'Ninject.3.2.2' because 'Ninject.Extensions.ChildKernel.3.2.0, Ninject.Extensions.Conventions.3.2.0, Ninject.Web.3.2.0, Ninject.Web.Common.3.2.0' depend on it.".
It was caused by multiple projects in the solution having a dependency on those DLLs and so package manager was not able to uninstall it.
The command with "uninstall package-name -RemoveDependency" too doesn't work here.
I removed the dependency one by one to fix it.
As #Schadensbegrenzer and #LeoLiu-MSFT pointed out, the Infrastrcuture assembly is not part of the .NET framework (anymore).
The issue has been reported as a bug on SimpleInjectors repo:
https://github.com/simpleinjector/SimpleInjector/issues/509
The package owners solution:
"I'll add this issue to the v4.1 backlog, and will fix the NuGet package (and that of SimpleInjector.Integation.MVC3 as well) with v4.1.
In the meantime, you can manually add the Microsoft.Web.Infrastructure NuGet package to your Web API project or don't add the SimpleInjector.Integration.WebApi.WebHost.QuickStart NuGet package to your project, but just the SimpleInjector.Integration.WebApi NuGet package and add the required code manually. The WebHost.QuickStart package is in fact nothing more than a reference to the integration package while injected some code into your application anyway.
The Web API integration page in the documentation describes how to set up a Web API project using Simple Injector."
I have asp.net 4 webforms website which references PortableLibrary project. In the website I serialize classes from PortableLibrary. When I deployed the project to webserver machine with IIS6 I'm getting following error:
Could not load file or assembly 'System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
the portable library project references System.Xml (v4.0.31029).
When I tried to deploy clean project without references, just with simple serialization of string object, it worked fine.
A tried assemblybinding in web config but without success.
Why I'm getting this error? I have no idea from where comes the '2.0.5.0' version of system.xml.
answer from here: http://visualstudiogallery.msdn.microsoft.com/b0e0b5e9-e138-410b-ad10-00cb3caf4981
which worked for me
We'll have clearer docs around this when we release, however, you need to have Update for Microsoft .NET Framework (KB2468871)[1] installed on the web server. You will also need to remove the the binding redirect - this will actually have the reverse effect of disabling the feature. :) [1] http://www.microsoft.com/downloads/en/details.aspx?FamilyID=41bdce1f-3cb3-44bb-9b33-23a1b8c99ac3&displaylang=en
I am getting the following WatiN error:
Unhandled Exception: System.IO.FileLoadException: Could not load file
or assembl y 'Interop.SHDocVw, Version=1.1.0.0, Culture=neutral,
PublicKeyToken=db7cfd3acb5 ad44e' or one of its dependencies. The
located assembly's manifest definition do es not match the assembly
reference. (Exception from HRESULT: 0x80131040) File name:
'Interop.SHDocVw, Version=1.1.0.0, Culture=neutral, PublicKeyToken=db
I copied the shDocvw.dll from System32 to the bin directory but still it is giving me the same problems.
If you've installed and referenced WatiN using NuGet in VS2010, you should already have the correct references, so they don't need to be removed and re-added. But you will still need to change the "Embed Interop Types" setting to False on the Interop.SHDocVw reference.
UPDATE: This answer was written before Nuget was released and applies only if you are NOT using Nuget to manage your dependencies. If you are using Nuget see the answer by #Nick Jones
I just had this issue today. You need to download the latest version of WatiN (I'm using 2.0.10.928) and reference the signed Interop.SHDocVw.dll that is provided by WatiN.
Try the follwoing:
Remove all other References to Interop.SHDocVw.dll
Right Click your solution and select 'Clean Solution'
Reference the Interop.SHDocVw.dll that is provided by WatiN
Build your solution.
Hope this helps.
UPDATE: Nick Jones is correct. This should not be an issue if you are using NuGet....but I was also getting this message when using MvcContrib.Mvc3.TestHelper-ci. At first glance it seems like the '-ci' packages is the way to go but I decided to use the MvcContrib.WatiN package for two reasons.
1) I don't get the "Could not load file or assembly" error message
2) The MvcContrib.Mvc3.TestHelper-ci is using an old version of WatiN.Core.dll (1.3.0.4000) where as the MvcContrib.WatiN package is using a newer version (2.0.0.99)
Check out the Properties of the Reference "Interop.SHDocVw.dll". Change the "Embed Interop Types" to False.
The problem is that it is not copying the dll file in your bin folder. But after this setting, it will do it properly.
I had the same error, and now its working fine.