How can I enable Assembly binding logging?
Asked Answered
I

10

63

I'm getting, "Could not load file or assembly 'Bla' or one of its dependencies. An attempt was made to load a program with an incorrect format."

A portion of the detailed info says:

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

So, thinking this may give me some insight in why I'm getting the error above (maybe the next YSOD would contain more explicit information about exactly why it's failing), I navigated to that location in the registry, but there is no such key that I can see. What it does have is:

\Fusion 
    (Default)   value not set
    \GACChangeNotification
    \NativeImagesIndex
    \PublisherPolicy

What am I missing?

Ingle answered 16/7, 2013 at 15:58 Comment(1)
Possible duplicate of How to enable assembly bind failure logging (Fusion) in .NETStochastic
L
75

A good place to start your investigation into any failed binding is to use the "fuslogvw.exe" utility. This may give you the information you need related to the binding failure so that you don't have to go messing around with any registry values to turn binding logging on.

Fuslogvw MSDN page

The utility should be in your Microsoft SDKs folder, which would be something like this, depending on your operating system: "C:\Program Files (x86)\Microsoft SDKs\Windows\v{SDK version}A\Bin\FUSLOGVW.exe"

  1. Run this utility as Administrator, from Developer Command Prompt (as Admin) type FUSLOGVW a new screen appears

  2. Go to Settings to and select Enable all binds to disk also select Enable custom log path and select the path of the folder of your choice to store the binding log.

  3. Restart IIS.

  4. From the FUSLOGVW window click Delete all to clear the list of any previous bind failures

  5. Reproduce the binding failure in your application

  6. In the utility, click Refresh. You should then see the bind failure logged in the list.

  7. You can view information about the bind failure by selecting it in the list and clicking View Log

The first thing I look for is the path in which the application is looking for the assembly. You should also make sure the version number of the assembly in question is what you expect.

Landowska answered 16/7, 2013 at 16:29 Comment(9)
If the settings are readonly, try running the tool as administratorBibliomania
Good answer but it didn't show any bind failures for me, even after I enabled logging of all bindings...Pellet
You could try setting the log path to a specific folder that you have access to. I've run into permissions related issues before. I just created an empty folder, gave permissions to everyone and pointed fuslogvw at it to get it working.Landowska
If you're building an ASP.NET MVC application (or possibly any other application involving IIS) restarting IIS was required to get the binding logs.Endocentric
if you see nothing in the log viewer then you can go to the settings and select "Enable all binds to disk". Then create a folder to which you can give all permissions. In the 'Log Settings' window where you just selected, check "Enable custom log path" and the path of the folder you just created. Restart IIS and browse to your site. You can see the logging now.Bottommost
FYI, I had to clear out my Internet Explorer cache by deleting temporary internet files. I don't even use Internet Explorer. See the note at the bottom of this page msdn.microsoft.com/en-us/library/e74a18c4(v=vs.110).aspxMeredithmeredithe
In later versions of .net you can also select "Log exeption text" and it just puts the error in the exception, no log required.Dirham
Downvoted, this is not the answer to the posted question.Hovercraft
@Hovercraft feel free to EDIT it and add what you consider an answer.Autocracy
M
32

Just create a new DWORD(32) under the Fusion key. Name the DWORD to EnableLog, and set it to value 1. Then restart IIS, refresh the page giving errors, and the assembly bind logs will show in the error message.

Exact registry path is [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion]. You can copy next text into a new file EnableLog.reg and double click the file.

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion]
"EnableLog"=dword:00000001
Mccoy answered 13/4, 2015 at 15:59 Comment(3)
How to create DWORD(32) ?Microcosm
Using regedit, navigate to the Fusion key. Right click in the empty space in the right-side pane. Expand "New" and you will see "DWORD(32-bit) Value" there.Mccoy
This solution enabled me to view the specific package I need to downgrade or upgrade.Cranial
M
13
  1. Create a new Application Pool

  2. Go to the Advanced Settings of this application pool

  3. Set the Enable 32-Bit Application to True

  4. Point your web application to use this new Pool

Screenshot (IIS-ApplicationPool)

Muzz answered 7/4, 2016 at 14:54 Comment(1)
This is not what the op asked for... This config will just force the web app to run as x32, even on an x64 system. A DLL compiled as x64 running in this app can be the root problem, but this setting has far more impact than just solving the issue.Leukas
D
4

For me the 'Bla' file was System.Net.http dll which was missing from my BIN folder. I just added it and it worked fine. Didn't change any registry key or anything of that sort.

Discountenance answered 14/12, 2018 at 13:26 Comment(0)
A
2

Per pierce.jason's answer above, I had luck with:

Just create a new DWORD(32) under the Fusion key. Name the DWORD to LogFailures, and set it to value 1. Then restart IIS, refresh the page giving errors, and the assembly bind logs will show in the error message.

Alizaalizarin answered 4/11, 2015 at 16:31 Comment(0)
B
2

Instead of Creating New Application Pool,You can go to your Existing application Pool->Right click Advance setting->Enable 32-bit Application-----Set to TRUE

Bename answered 27/4, 2016 at 13:56 Comment(0)
E
1

If you sometimes run different versions of your application, make sure you delete 'Bla' from the application bin directory if the version running doesn't need it.

Enliven answered 31/12, 2013 at 16:51 Comment(0)
U
1

This error comes for me in windows application while calling server dll from client. After system restart it works fine

Unwary answered 21/2, 2019 at 16:56 Comment(0)
S
1

In my case, the issue resolved when I cleaned the solution and build it again. Worth a try!

Supersensitive answered 15/8, 2022 at 8:50 Comment(0)
F
0

When I had the same problem I fixed it by deleting the existing key.snk in that project and adding a new key.

Flagellate answered 9/9, 2014 at 11:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.