I have a web application which is made up of web forms. Slowly we are converting it over to MVC.
Last week I did a deploy to a testing environment and everything works as expected.
This week I made some changes to some ASPX/code behind files and also some user controls. I did a publish/deploy to testing and I receive an error when I browse to the site through IIS.
The error is:
Could not load file or assembly 'Microsoft.Owin, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e37' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Comparing the bin folder of the last good deploy, to the broken deploy, the only difference is the broken deploy has one extra file - Microsoft.Owin.Host.SystemWeb.dll
If I remove that file the website is able to load and function correctly.
The website has many projects and references, the root project (the one I right click > publish on) does not have a reference to this Microsoft.Owin.Host.SystemWeb.dll so it must be referenced from another project.
Is there any way to fix this error without having to delete the file from the bin folder? What is causing the error?
Also both bin folders have other Owin dll files.
Microsoft.Owin.dll
Microsoft.Owin.Security.Cookies.dll
Microsoft.Owin.Security.dll
Owin.dll
It sounds like one of your projects use the OWIN middleware. It also seems like someone may have tried to update the package and possibly did not do it properly. I would right-click on the solution and click "Manage NuGet Packages" and re-install the OWIN packages. If that does not work its likely a binding redirect issue that needs to be resolved in the web.config. You may also want to see if there are any OWIN references even being used in the project.
Related
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.
I'm working on an error that I'm getting in a WinForms application that was recently updated from .Net framework 4.5.2 to 4.7. The issue occurs only after the application has been deployed. The error is originating from inside a WCF service (.svc) that I'm using. The specific error text I'm getting is:
Could not load file or assembly 'System.Net.Http, Version=4.1.1.1,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
dependencies. The system cannot find the file specified.
In attempting to resolve this issue, I adjusted the App.Config file to bindingRedirect from System.Net.Http version 4.1.1.1 to 4.3.2 (which doesn't actually exist).
This resolved the issue with the service; however, when I made a call to System.Net.Http to download a string, the call failed. Presumably, this is because I directed System.Net.Http to use a dependency that does not actually exist (4.3.2).
This means currently I have a choice: either the service works, or calls directly to System.Net.Http work, but not both. Is anyone aware of how to make the service able find System.Net.Http 4.1.1.1? It is installed via NuGet... just seemingly not recognized unless:
1) I issue a binding redirect to a version of System.Net.Http that doesn't actually exist.
OR
2) I run the program in debug/release mode from Visual Studio (deployed release doesn't work).
I've found the issue, after several days of trouble. System.Net.Http is not published as it is supposed to be. It is a known issue (that is resolved, in theory), found here:
https://blogs.msdn.microsoft.com/bclteam/p/httpclient/
Issue 8
Symptom
ClickOnce applications targeting .NET Framework 4.0 that reference the Microsoft.Net.Http package may experience a TypeLoadException or other errors after being installed.
Resolution
This occurs because ClickOnce fails to deploy certain required assemblies. As a workaround, do the following:
1.Right-click on the project and choose Add Existing Item
2.Browse to the HttpClient net40 package folder
3.In the File name text box enter *.*
4.Holding CTRL, select System.Net.Http.dll and System.Net.Http.Primitives.dll
5.Click the down-arrow next to the Add button and choose Add as Link
6.In Solution Explorer, holding CTRL select System.Net.Http.dll and System.Net.Http.WebRequest.dll
7.Right-click the selection, choose Properties and change Copy to Output Directory to Copy always
8.Republish
So, I've got a C# windows workflow project that creates a report programmatically and emails it out. It works fine on my local machine, but putting it on a scheduler in a different machine generates the following error:
Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Based on other topics, I tried installing MICROSOFT® REPORT VIEWER 2012 RUNTIME from the following address: http://www.microsoft.com/en-us/download/details.aspx?id=35747. This didn't help. This was the overwhelmingly prevalent solution, but I'd love any other suggestions or advice.
The accepted answer pointed me in the right direction. However, didn't provide enough details for me to reach resolution. I wanted to add this as a comment to that answer but it was too long.
In my VS project, I had a reference to Microsoft.ReportViewer.WinForms version 12.0.0.0 and when deploying to another computer got the same error as present in this question. The key to the problem is a portion of the error:
The located assembly's manifest definition does not match the assembly
reference.
It is telling you that it found a DLL with the right name, but it is the wrong version. I had added a reference to Microsoft.ReportViewer.Common through the references dialog but I didn't catch that the only one listed in the "Extensions" section of the references dialog was for version 10.0.0.0. So of course it will deploy the wrong one if you are telling it to deploy the wrong one.
What you have to do is find the Microsoft.ReportViewer.Common.dll file with version 12.0.0.0 on your system and manually include a reference to that. For me it was in the following directory:
C:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.Common\12.0.0.0__89845dcd8080cc91\
Once I added that reference and set both DLLs to Copy Local in my VS project, then everything worked on the deployed machine.
Note: I did not require an installation of the Microsoft Report Viewer 2012 Runtime in order to have it work on the deployed machine. For any of you like me that were wanting to avoid any other installations during deployment.
try to add the dll files to the project from :
C:\Program Files\Microsoft Visual Studio 10.0\ReportViewer
add them to the bin folder after publishing the project
I have a ASP.NET project running on IIS7. I just adding Microsoft.Practices.EnterpriseLibrary.Common.dll, Microsoft.Practices.EnterpriseLibrary.Data.dll, & Microsoft.Practices.EnterpriseLibrary.ObjectBuilder2.dll.
I am receiving this error:
Error 2 Could not load file or assembly 'Microsoft_Practices_EnterpriseLibrary_Common' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I researched the issue and found this means that the dll is not in the right location but it is in my projectdirectory/bin folder. So I do not understand where else it should be referenced. It isn't referenced in my Web.config but assemblies tag was not generated in the project template.
Do I need to reference these assemblies? If so, where do I find the necessary attributes i.e. PublicToken, etc.?
Sometimes this problem occurs with other tools/frameworks as well. Without pulling your hair out, just add a reference to the missing assembly and make sure to set those references to "Copy Local" = true. I notice with framework APIs that are placed in the GAC tend to have this issue.
If its a "web site" project you can just throw the dlls in the bin folder. However if its a "web application" project, you'll need to add a reference and set copy local=true.
I have corrected the issue. I'm not sure why but I had to create a new folder in my project and moved the dll's there and I was able to build the solution. This is a web site project.
Could not load file or assembly '__App_Code' or one of its
dependencies. The located assembly's manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)
I have just converted my Website project to Web Application project, but am unable to run the web site either through IIS or through Visual Studio's development server as well, although it is successfully built...
Same error is prompted in both the cases. Can anybody help me on this?
I have tried renaming my App_Code folder to 'CodeFiles' just to check out, but the problem persists. I tried emptying the Temporary Internet Files folder as well, but to no avail...
I have solved the problem with Aamir's help. It was quite obvious. The entry was in the csproj file for __App_Code. Removing that entry worked...