. Advertisement .
..3..
. Advertisement .
..4..
I get an error
System.IO.FileLoadException: Could not load file or assembly 'Utility, Version=1.2.0.200, 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)**
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)
when trying to run some unit tests in a C# Windows Forms application (VS 2005). How to fix the the located assembly’s manifest definition does not match the assembly reference error? Please give me some advice.
The cause: As this assembly doesn’t quite match what was requested, you will receive this error. Because the.NET Assembly loader cannot find
1.2.0.203
while it finds a1.2.0.200.
You can simply understand that it can’t find the assembly that was mentioned. Put it in the GAC or the application path to ensure it can find the proper assembly.
Solution:
Any assembly version will be redirected to the version
3.1.0.0
using the code below. We have a script that will always renew this reference in theApp.config
, ensuring that we never need to deal with this problem again.You may obtain the assembly
publicKeyToken
and generate this block from the.dll file itself by using reflection.To resolve this problem, there are a few things you can do. To search your hard disk for the assembly (.dll), use Windows file search. After you have a list, click View->Choose details and then select “File Version”. This will show you the version number in your list of results.
Lars also suggested that you check your GAC to determine which version is there. The Microsoft article states assemblies in the GAC cannot be copied locally during a build. You might have to remove the older version before you do a complete rebuild.
To find out more about binding failures, use fuslogvw.exe that comes with Visual Studio. Microsoft provides information on this tool. You will need to enable logging by changing the
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion\EnableLog
registry key.