Checking assembly dependencies for .NET
Are you getting the dreaded "Could not load file or assembly" error in C#? Well there might be several causes of that, the most difficult to track down and fix is a missing assembly dependency.
The exception that is usually generated is along similar to this one:
at x.Foo.FooGO() at x.Foo.Foo2(String groupName_) in Foo.cs:line 123 at x.Foo.UnitTests.FooTests.TestFoo() in FooTests.cs:line 98
System.IO.FileLoadException: Could not load file or assembly 'Utility, Version=1.2.0.203, Culture=neutral, PublicKeyToken=764d581291d764f7' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
This exception means one of two things, you are missing a direct reference (or version) to the DLL that you are attempting to use... or that a DLL that your DLL references is missing or is the incorrect version.
In the case of the later, you can enable Assembly reference logging by adding a registry value under HKLM\Software\Microsoft\Fusion. Add a DWord entry named EnableLog and set its value to 1. This will allow you to see where the missing assembly was first referenced from.
From that point, you can load a tool called CheckAsm, found here: http://checkasm.booring.net/. With this tool, you can load an assembly and view all of its dependencies, it will show you the references and which are currently missing. The best feature of CheckAsm is that you can scan an entire directory. From there, it's a matter of fixing the references either by adding the dependencies or modifying the DLL to point to the correct dependencies.
Recent blog posts
- Quick Memory Improvement for Firefox
- Canned VirtualPC Instances for IE 6, 7, 8 on XP/Vista
- Checking assembly dependencies for .NET
- Google's Public DNS
- Server Utility Functions for Non-Web Apps
- reCAPTCHA for ASP.NET MVC that uses ModelState
- Adding a container to ValidationSummary helper in ASP.NET MVC
- Generic XML Serialization Class
- Re-throwing Exceptions in C# with InternalPreserveStackTrace
- Solving xsd generation error: 'The element .... is missing'
Recent comments
3 days 8 min ago
4 days 2 hours ago
4 days 2 hours ago
4 days 20 hours ago
4 days 20 hours ago
2 weeks 21 hours ago
6 weeks 17 hours ago
22 weeks 3 days ago
23 weeks 2 days ago
1 year 8 weeks ago