Use Fusion Log to diagnose the "cocould not load file or assembly" Problem

Source: Internet
Author: User

Today, I encountered a strange problem: there is an ASP. NET project, and the error of not loading EF4.1 is always displayed during access (the references to EF in the project have been upgraded to EF5.0 ):

Cocould not load file or assembly 'entityframework, Version = 4.1.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089 'or one of its dependencies. the located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Note: unprocessed exceptions occur during the execution of the current Web request. Check the stack trace information for details about the error and the source of the error in the code.

Exception details: System. IO. fileLoadException: cocould not load file or assembly 'entityframework, Version = 4.1.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089 'or one of its dependencies. the located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Source error:

An unhandled exception is generated during the execution of the current Web request. You can use the following exception stack trace information to determine the cause and location of the exception.

Assembly Loading trace: The following information helps determine why the assembly "EntityFramework, Version = 4.1.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089" fails to be loaded.

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM \ Software \ Microsoft \ Fusion! EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM \ Software \ Microsoft \ Fusion! EnableLog].

The strange problem is that I searched for the code of the entire project and did not find any reference to Entity Framework 4.1.0.0.

Later, I noticed the error message "dTo enable assembly bind failure logging, set the registry value [HKLM \ Software \ Microsoft \ Fusion! EnableLog] (DWORD) to 1 ", wondering if you can use the log to find out where EF 4.1 is referenced. Go to the Registry and check that there are HKLM \ Software \ Microsoft \ Fusion, but there are no HKLM \ Software \ Microsoft \ Fusion! EnableLog. I don't know how to start it?

I searched the internet and found the answer of How to enable assembly bind failure logging (Fusion) in. NET on stackoverflow:

Add the following values
HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Fusion
Add:
DWORD ForceLog set value to 1
DWORD LogFailures set value to 1
DWORD LogResourceBinds set value to 1
String LogPath set value to folder for logs ie) C: \ FusionLog \

So we made the following settings in the registry:

Then, the error message displayed on the page contains the following line:

Calling assembly: Devtalk. EF. CodeFirst, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null.

In C: \ FusionLog \ Default \ 64baea7c, you can also find the corresponding log file EntityFramework, Version = 4.1.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089. HTM

So, the truth is: This project references Devtalk. EF. CodeFirst. dll, And it references Entity Framework 4.1, which causes this problem.

Update:

If you do not want to generate a log file, you only want to display "Calling assembly" in the error message ", you only need to set the value of LogResourceBinds to 1 (DWORD (32-bit) in the Registry HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Fusion )).

Note: After you modify the registry, You need to restart IIS to take effect.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.