I’m having another of these «Could not load file or assembly or one of its dependencies» problems.
Additional information: Could not load
file or assembly
‘Microsoft.Practices.Unity,
Version=1.2.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)
I have no idea what is causing this or how I could debug it to find the cause.
I’ve done a search in my solution catalogs .csproj files, and every where I have Unity I have:
Reference
Include=»Microsoft.Practices.Unity,
Version=2.0.414.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35,
processorArchitecture=MSIL»
Can’t find any reference anywhere which goes against 1.2.0.0 in any of my projects.
Any ideas how I should go about solving this?
TylerH
20.7k65 gold badges73 silver badges98 bronze badges
asked Dec 17, 2010 at 11:13
7
-
Check if you are referencing an assembly which in turn referencing an old version of unity. For example let’s say you have an assembly called
ServiceLocator.dll
which needs an old version of Unity assembly, now when you reference theServiceLocator
you should provide it with the old version of Unity, and that makes the problem. -
May be the output folder where all projects build their assemblies, has an old version of unity.
You can use FusLogVw to find out who is loading the old assemblies, just define a path for the log, and run your solution, then check (in FusLogvw) the first line where the Unity assembly is loaded, double click it and see the calling assembly, and here you go.
Slime recipe
2,2133 gold badges32 silver badges49 bronze badges
answered Dec 17, 2010 at 11:30
NourNour
5,1923 gold badges41 silver badges65 bronze badges
2
Open IIS Manager
Select Application Pools
then select the pool you are using
go to advanced settings (at right side)
Change the flag of Enable 32-bit application false to true.
answered Oct 7, 2013 at 10:58
kranthikranthi
9656 silver badges2 bronze badges
4
For me, none of the other solutions worked (including the clean/rebuild strategy). I found another workaround solution which is to close and re-open Visual Studio.
I guess this forces Visual Studio to re-load the solution and all the projects, rechecking the dependencies in the process.
answered Feb 15, 2012 at 5:27
RobotnikRobotnik
3,6133 gold badges31 silver badges49 bronze badges
1
Try to clean Debug and Release folders in your solution. Then remove and add unity again.
BlaM
28.3k32 gold badges90 silver badges105 bronze badges
answered Dec 17, 2010 at 11:28
Aleksei AnufrievAleksei Anufriev
3,2061 gold badge26 silver badges31 bronze badges
4
Despite the original question being posted five years ago, the problem still persists and is rather annoying.
The general solution is thorough analysis of all referenced assemblies to understand what’s going wrong. To make this task easier I made a tool (a Visual Studio extension) which allows selecting a .NET assembly (a .dll
or .exe
file) to get a graph of all the referenced assemblies while highlighting conflicting or missing references.
The tool is available in Visual Studio Gallery: https://marketplace.visualstudio.com/vsgallery/051172f3-4b30-4bbc-8da6-d55f70402734
Example of output:
Jeremy Caney
7,01563 gold badges48 silver badges76 bronze badges
answered May 29, 2017 at 22:34
5
At 99% the Could not load file or assembly or one of its dependencies problem is caused by dependencies! I suggest you follow this steps:
-
Download Dependency Walker from http://www.dependencywalker.com/
-
Launch Dependency Walker and open the dll (in my case
NativeInterfaces.dll
) -
You can see one or more dll with the error in red Error opening file…
-
It means that this dll is missing in your system; in my case the dll name is
MSVCR71.DLL
-
You can download missings dll from google and copy in right path (in my case
c:windowssystem32
) -
At this point, you must register the new dll in the GAC (Global Assembly Cache): open a DOS terminal and write:
cd WindowsSystem32 regsvr32 /i msvcr71.dll
-
Restart your application
radbyx
9,30221 gold badges84 silver badges127 bronze badges
answered May 27, 2016 at 12:47
3
Following worked for me.
- Remove Temporary Files C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files
- Close VSTS and Open Again
- Remove and Add the same DLLs (Note: you add the same matching versions)
answered Mar 22, 2013 at 7:22
Riddhi M.Riddhi M.
1952 silver badges9 bronze badges
0
Microsoft Enterprise Library (referenced by .NetTiers) was our problem, which was in turn referencing an older version of Unity. In order to solve the problem we used the following binding redirection in the web.config:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Practices.Unity" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0-2.0.414.0" newVersion="2.1.505.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Practices.Unity.Configuration" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0-2.0.414.0" newVersion="2.1.505.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Alternatively, you may want to just update the Enterprise Library to the latest version.
answered Jul 3, 2012 at 10:03
RebeccaRebecca
13.9k10 gold badges95 silver badges135 bronze badges
In solution explorer right click on project (not solution), in build tab choose Platform target : «Any CPU».
answered Sep 26, 2016 at 14:12
1
Check the Web.config/App.config file in your project. See if the version numbers are correct.
<bindingRedirect oldVersion="X.X.X.X-X.X.X.X" newVersion="X.X.X.X" />
This worked for me.
answered Apr 7, 2015 at 17:29
Jaseem AbbasJaseem Abbas
5,0085 gold badges47 silver badges72 bronze badges
1
Juntos answer is correct but you should also consider:
For the unity v2.1.505.2 different AssemblyVersion and AssemblyFileVersion attributes are specified:
AssemblyFileVersion is used by the NuGet but CLR does not care about it!
CLR is going to use only AssemblyVersion!
So your redirects should be applied to a version that specified in AssemblyVersion attribute. So 2.1.505.0 should be used
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity name="Microsoft.Practices.Unity" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.505.0" newVersion="2.1.505.0" />
</dependentAssembly>
</assemblyBinding>
See also:
What are differences between AssemblyVersion, AssemblyFileVersion and AssemblyInformationalVersion?
answered Nov 26, 2014 at 11:15
IevgenIevgen
4,2507 gold badges75 silver badges124 bronze badges
I also got this terrible error and found a solution for this…
- Right Click on the Solution name
- Click Clean Solution
- Restart Visual Studio
- Goto project Properties >> Build
- Change Configuration to Release
- Start Debugging (F5)
1) , 2)
4) , 5)
Hope this will help you also.
answered Sep 17, 2015 at 18:24
Roshana PitigalaRoshana Pitigala
8,3578 gold badges47 silver badges78 bronze badges
I had the same problem i solved it via the instructions below:
- open tools menu and select option
- in options, window go to Projects and Solutions/Web Projects
- check
use the 64bit version of IIS ...
answered Jun 12, 2019 at 8:31
0
- Goto :Solution -> Package
- Click on Advanced Tab (Find below the page)
- Add your dll to additional assemblies(this way we can add external dlls in sharepoint).
answered Sep 12, 2013 at 6:26
1
Not sure if this might help.
Check that the Assembly name and the Default namespace in the Properies in your asemblies match. This resolved my issue which yielded the same error.
zero323
320k101 gold badges952 silver badges932 bronze badges
answered Apr 17, 2012 at 10:27
SjaanSjaan
511 silver badge1 bronze badge
1
In my case in the bin folder was a non reference dll called Unity.MVC3 , i tried to search any reference to this in visual studio without success, so my solution was so easy as delete that dll from the bin folder.
answered Jan 5, 2016 at 0:00
TotodileTotodile
1501 silver badge7 bronze badges
Thanks Riddhi M.
Following worked for me.
Remove Temporary Files C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files
Close VSTS and Open Again
Remove and Add the same DLLs (Note: you add the same matching versions)
answered Jul 30, 2015 at 13:29
1
You say you have a lot of projects in your solution … well, start with one near the top of the build order. Get that one to build and once you figure it out you can apply the same fix to the rest of them.
Honestly, you probably just need to refresh your reference. It sounds like you either updated your version and didn’t update the references, or it’s a relative path issue if you keep your solution in source control. Just verify your assumptions, and re-add the reference.
answered Dec 17, 2010 at 11:30
Joel MartinezJoel Martinez
46.7k26 gold badges129 silver badges185 bronze badges
if you are getting this error message by opening an application on you windows xp it mean first you have installed that app due to its not working without net framework 4 and service pack 3 . you installed both and again you are getting this error so you should reinstall that app again but first uninstall from add and remove
if this not work please dont abuse me . i am also a junior
answered Nov 16, 2013 at 8:14
Following worked for me.
- Remove Temporary Files C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files
- then right click on Temporary Asp.net Files>properties>security
and give total control access to IIS and to all user runing my project
- then right click on Temporary Asp.net Files>properties>security
answered Mar 6, 2015 at 15:38
onlymeonlyme
3,7562 gold badges22 silver badges17 bronze badges
This issue happened to me where one of my dependent libraries was compiling a DLL with «Any CPU» when the parent library was expecting a compilation of «x64».
answered Nov 16, 2016 at 17:21
1
I had this today, and in my case the issue was very odd:
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Host.SystemWeb" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.0" newVersion="3.1.0.0" />
</dependentAssembly>0.
Note the stray characters at the end of the XML — somehow those had been moved from the version number to the end of this block of XML!
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Host.SystemWeb" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
</dependentAssembly>
Changed to the above and voila! Everything worked again.
answered May 12, 2017 at 9:16
garrypgarryp
5,4711 gold badge29 silver badges40 bronze badges
Tried closing and re-opening VS as suggested but it didn’t work out.
I had to change from MIXED PLATFORMS to ANY CPU.
answered Aug 30, 2021 at 14:58
Bartho BernsmannBartho Bernsmann
2,4331 gold badge25 silver badges33 bronze badges
0
You have to delete Your appname.dll file from your output folder.
Cleanup Debug and Release folders.
Rebuild and copy to output folder regenerated dll file.
answered May 15, 2013 at 7:44
guccigucci
211 bronze badge
I «Set as Startup Project» the unloaded/unfound library/project.
Then deployed it.
It worked!
I think it couldn’t found the .dll because it was not in the assembly at first.
answered Jul 16, 2013 at 5:08
niravnirav
3733 gold badges7 silver badges20 bronze badges
Another possible cause: make sure you haven’t accidentally given both of the projects the same assembly name in project properties.
answered Dec 21, 2014 at 16:33
nathancherenathanchere
7,93815 gold badges65 silver badges85 bronze badges
1
My solution for .NET 4.0, using Enterprise Library 5, was to add a reference to:
Microsoft.Practices.Unity.Interception.dll
answered Jun 5, 2015 at 19:44
EntreeEntree
18.3k38 gold badges159 silver badges242 bronze badges
Look out for conflicting references. Even after a clean and rebuild, conflicting references will still cause a problem. My problem was between AForge and Accord. I removed both of the references, and re-added the references re-choosing the particular reference (particular to my case, just Accord).
answered Mar 25, 2016 at 19:05
user3791372user3791372
4,3955 gold badges43 silver badges77 bronze badges
In my case, none of the proposed answer worked.
Here is what worked for me:
- Remove the reference
- Rename the DLL
- Import the reference again
The second step was important apparently as it did not work without it.
answered Jun 23, 2016 at 8:38
Nicolas RaoulNicolas Raoul
58.4k58 gold badges221 silver badges370 bronze badges
Try checking if the «Copy to Local» property for the reference is set to true and the specific version is set to true. This is relevant for applications in Visual Studio.
answered Jul 6, 2016 at 15:33
Hi friends, in this article, we will be discussing about, how to resolve the below error, when working with CLR assemblies in SQL Server:
An error occurred in the Microsoft .NET Framework while trying to load assembly id… The server may be running out of resources, or the assembly may not be trusted. Run the query again, or check documentation to see how to solve the assembly trust issues. For more information about this error: System.IO.FileLoadException: could not load file or assembly …
How to Resolve the Issue
In order to resolve the issues, there is a series of steps that you can try.
Step 1: Check if CLR is Enabled in the SQL Server Instance
The first thing to check, which is quite obvious, is whether CLR is enabled or not, in the specific SQL Server instance.
In order to check this, you just need to run in SSMS the below T-SQL statement:
sp_configure 'clr enabled'; GO
In the “run_value” is set to 1, it means that CLR is indeed enabled.
If it is not enabled and you have the approval to indeed enable it, you can do so, using the below T-SQL statements:
sp_configure 'clr enabled',1; GO RECONFIGURE WITH OVERRIDE; GO
Step 2: Check the CLR Assembly File Path References
The next step, is to check the CLR assemblies that are loaded into the SQL Server instance.
To do so, you need to run the following SELECT T-SQL statement:
SELECT * FROM sys.assembly_files; GO
Based on the query results, you should make sure that the assemblies listed, are indeed located in the referenced file path.
If a reference assembly file (dll) is missing, then that’s the problem and you need to register again the assembly (step 4a).
Step 3: Check the Loaded Assemblies
The next step, is to check the CLR assemblies that are loaded into the SQL Server instance.
To do so, you need to run the following SELECT T-SQL statement:
SELECT * FROM sys.dm_clr_loaded_assemblies; GO
If the above query does not return anything, then bingo, you just found the problem!
So, in this case, it means that your CLR assembly is not properly registered and you need to refresh it (step 4b).
Step 4a: Registering the CLR Assembly Again in SQL Server
So, if the issue was identified in Step 2, then it means you need to re-register the specific CLR assembly in SQL Server.
To this, you can run the following T-SQL statement:
--Recommendation: Only use CLR Assemblies with SAFE permissions CREATE ASSEMBLY [ASSEMBLY_NAME] FROM 'path to assembly .dll file' WITH PERMISSION_SET = [SET THE PERMISSION SET HERE: SAFE, UNSAFE OR EXTERNAL]
Step 4a: Refreshing the CLR Assembly in SQL Server
So, if the issue was identified in Step 3, then it means you need to refresh the specific CLR assembly in SQL Server.
To this, you can run the following T-SQL statement:
ALTER ASSEMBLY [ASSEMBLY_NAME] FROM 'path to .dll file'; GO
Learn more about SQL Server Development – Enroll to our Course!
Enroll to our online course titled “Essential SQL Server Development Tips for SQL Developers” (special limited-time discount included in link) and sharpen your SQL Server database programming skills via a large set of tips on T-SQL and database development techniques. The course, among other, features over than 30 live demonstrations!
Enroll from $12.99
Featured Online Courses:
- SQL Server 2022: What’s New – New and Enhanced Features
- Working with Python on Windows and SQL Server Databases
- Introduction to Azure Database for MySQL
- Boost SQL Server Database Performance with In-Memory OLTP
- Introduction to Azure SQL Database for Beginners
- Essential SQL Server Administration Tips
- SQL Server Fundamentals – SQL Database for Beginners
- Essential SQL Server Development Tips for SQL Developers
- Introduction to Computer Programming for Beginners
- .NET Programming for Beginners – Windows Forms with C#
- SQL Server 2019: What’s New – New and Enhanced Features
- Entity Framework: Getting Started – Complete Beginners Guide
- Data Management for Beginners – Main Principles
- A Guide on How to Start and Monetize a Successful Blog
Read Also:
- Essential SQL Server Development Tips for SQL Developers (Course Preview)
- Resolve SQL Server CTE Error – Incorrect syntax near ‘)’.
- The TempDB System Database in SQL Server
- SQL Server Installation and Setup Best Practices
- The feature you are trying to use is on a network resource that is unavailable
- SQL Server 2016: TempDB Enhancements
- tempdb growth
- Introduction to SQL Server Machine Learning Services
- Essential SQL Server Administration Tips
- What are SQL Server Statistics and Where are they Stored?
- Tip of the Week No.1 – SQL Server Always Encrypted
- Tip of the Week No.3 – TempDB Settings During Installation
- Tip of the Week No.6 – About SQL Server Temporary Tables
- Tip of the Week No.19 – What is the Database First Workflow in Entity Framework?
- Tip of the Week No.20 – SQL Server Surface Area
- Within Which Context Does SQL Server Access Network Resources?
- Troubleshooting the File Activation Error in SQL Server
Subscribe to our newsletter and stay up to date!
Subscribe to our YouTube channel (SQLNetHub TV)
Check our eBooks!
Rate this article: (1 votes, average: 5.00 out of 5)
Loading…
Reference: SQLNetHub.com (https://www.sqlnethub.com)
© SQLNetHub
Artemakis Artemiou is a Senior SQL Server Architect, Author, a 9 Times Microsoft Data Platform MVP (2009-2018). He has over 20 years of experience in the IT industry in various roles. Artemakis is the founder of SQLNetHub and {essentialDevTips.com}. Artemakis is the creator of the well-known software tools Snippets Generator and DBA Security Advisor. Also, he is the author of many eBooks on SQL Server. Artemakis currently serves as the President of the Cyprus .NET User Group (CDNUG) and the International .NET Association Country Leader for Cyprus (INETA). Moreover, Artemakis teaches on Udemy, you can check his courses here.
Views: 1,412
Artemakis Artemiou is a Senior SQL Server Architect, Author, a 9 Times Microsoft Data Platform MVP (2009-2018). He has over 20 years of experience in the IT industry in various roles. Artemakis is the founder of SQLNetHub and {essentialDevTips.com}. Artemakis is the creator of the well-known software tools Snippets Generator and DBA Security Advisor. Also, he is the author of many eBooks on SQL Server. Artemakis currently serves as the President of the Cyprus .NET User Group (CDNUG) and the International .NET Association Country Leader for Cyprus (INETA). Moreover, Artemakis teaches on Udemy, you can check his courses here.
Views: 1,412