ASP.NET - Assembly Not Found - c#

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.

Related

ASP loading assembly(dll) error

I have an ASP application and I am using the functionality of exporting to Word ( from my RadEditor).
Now I have the following dll and I have placed it in the right folder from where the system should reference it and I want my system to reference only this version of dll :-
Telerik.Windows.Documents.Core.dll
Version 2016.3.1021.40
But whenever I am doing exporting to word it is throwing the below error :-
Could not load file or assembly 'Telerik.Windows.Documents.Core, Version=2015.3.930.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Now can anyone please advise why my system is pointing to Version=2015.3.930.45 when I have Version 2016.3.1021.40, and I did not keep any other version of that dll except the Version 2016.... anywhere in my entire project or what can be done in this situation . ThankYou !
You can try any of the following:
The reference in the config file entry is still pointing to old version. Try to remove the dll and clear the entry in config and re-add
Sometimes cleaning the solution and re-building should simply fix this. (you can try cleaning bin and obj folders manually before doing this)
Remove Temporary Files C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
Or any other Telerik DLL which has dependency on this is still using the older version. Try to update all the DLLs related to Telerik Or try to use the DLLs of same versions

Microsoft.Owin.Host.SystemWeb dll appearing in deploys

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.

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!

Could not load file or assembly '__App_Code' or one of its dependencies

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

Assembly reference resolves to different path than what was specified

I'm trying to reference Oracle.DataAccess.dll in my c# project assembly. When running the project I get the following error:
Could not load file or assembly 'Oracle.DataAccess, Version=2.112.2.50, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I'm really confused because when I right click references and add an assembly I navigate to a copy of the dll that I have in a folder contained within the project and add the reference. When I look at the properties of the reference, though, it shows a path of
C:\Program Files\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\Profile\Client\Oracle.DataAccess.dll
and sure enough there is a dll in there by that name, but it's an old version. Why does this reference not point to the path that I specified when adding it, and how can I get it to use the dll at the location that I specified?
We take a couple of steps to resolve issues like this when we know that the specific version does not matter to the built application:
1) In the properties for the reference within the project, ensure the Specific Version property is set to False.
2) Save the project, the edit it in notepad or the text editor of your choice. Find the DLL reference and remove all version and key information and ensure the hint path points to your copy of the file. For example:
<Reference Include="Oracle.DataAccess">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Assemblies\Oracle.DataAccess.dll</HintPath>
</Reference>
Visual Studio can be a bit flaky when it comes to references. Many times we have to just edit the project file directly. Setting the properties of the reference directly doesn't always stick. Right-click your project, select Edit Project File, and make the change there. It should stick.

Categories

Resources