How do I enable assembly bind failure logging (Fusion) in .NET?
14 Answers
Add the following values to
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 DWORD EnableLog set value to 1 String LogPath set value to folder for logs (e.g. C:\FusionLog\)
Make sure you include the backslash after the folder name and that the Folder exists.
You need to restart the program that you're running to force it to read those registry settings.
By the way, don't forget to turn off fusion logging when not needed.
-
27Gary's solutions worked for me although I also had to follow by resetting IIS. Note I configured this in a clean environment where I didn't want to install SDKs and the like.– MichhesCommented Jul 30, 2010 at 2:21
-
5Been reported by some that registry change does not take right away. Have you tried turning Fusion logging on then rebooting? Commented Dec 6, 2010 at 20:18
-
61You need to restart whatever program it is you're running for it to read those registry settings Commented Mar 28, 2011 at 22:29
-
64The Fusion Log Viewer does all that for you. Go to Start -> Programs -> Visual Studio xxxx > Visual Studio Tools > Visual Studio Command Prompt (run as admin) and type "fuslogvw". In Settings you adjust the logging.– r3markCommented Jun 4, 2013 at 3:09
-
14
I usually use the Fusion Log Viewer (Fuslogvw.exe from a Visual Studio command prompt or Fusion Log Viewer from the start menu) - my standard setup is:
- Open Fusion Log Viewer as administrator
- Click settings
- Check the Enable custom log path checkbox
- Enter the location you want logs to get written to, for example,
c:\FusionLogs
(Important: make sure that you have actually created this folder in the file system.) - Make sure that the right level of logging is on (I sometimes just select Log all binds to disk just to make sure things are working right)
- Click OK
- Set the log location option to Custom
Remember to turn of logging off once you're done!
(I just posted this on a similar question - I think it's relevant here too.)
-
4Note that in cases where you are hosting the runtime yourself from a native application you will be required to use a custom log path for some reason otherwise you won't get anything logged.– jpiersonCommented Oct 4, 2012 at 3:34
-
At least in my situation, I didn't actually have to set the custom log paths. All I had to do was turn logging on, e.g., "Log all binds to disk" on the settings dialog.– JoshCommented Jul 31, 2014 at 20:11
-
52Run as Administrator was required in my case, otherwise all options were disabled.– vezenkovCommented Aug 12, 2016 at 12:32
-
2
-
6Make sure you are running
fuslogvw
not only as admin but also from the correct Windows SDK path the Visual Studio project throwing the exception is using. Check its csproj and search for SDK within (my sdk node is namedTargetFrameworkSDKToolsDirectory
). Using a non matching fuslogvw version seems to not catch the exceptions (which makes sense...)– VeverkeCommented Jun 12, 2017 at 14:28
If you have the Windows SDK installed on your machine, you'll find the "Fusion Log Viewer" under Microsoft SDK\Tools (just type "Fusion" in the start menu on Vista or Windows 7/8). Launch it, click the Settings button, and select "Log bind failure" or "Log all binds".
If these buttons are disabled, go back to the start menu, right-click the Log Viewer, and select "Run as Administrator".
-
6
-
14@Tim, not seen that before - could it be to do with Admin privileges? It is HKEY_LOCAL_MACHINE that is being modified after all. Commented Sep 24, 2010 at 15:35
-
2"Settings, Log bind failures" was enough to find my problem.– pauloyaCommented Aug 16, 2011 at 12:00
-
1Make sure the folder allows write access. UAC and c:\logs do not play nice with the fusion log Commented Feb 20, 2013 at 9:27
-
4Just as a note, if the buttons are disabled, re-run fusion log viewer with admin privileges. Commented Mar 7, 2013 at 19:33
You can run this Powershell script as administrator to enable FL:
Set-ItemProperty -Path HKLM:\Software\Microsoft\Fusion -Name ForceLog -Value 1 -Type DWord
Set-ItemProperty -Path HKLM:\Software\Microsoft\Fusion -Name LogFailures -Value 1 -Type DWord
Set-ItemProperty -Path HKLM:\Software\Microsoft\Fusion -Name LogResourceBinds -Value 1 -Type DWord
Set-ItemProperty -Path HKLM:\Software\Microsoft\Fusion -Name LogPath -Value 'C:\FusionLog\' -Type String
mkdir C:\FusionLog -Force
and this one to disable:
Remove-ItemProperty -Path HKLM:\Software\Microsoft\Fusion -Name ForceLog
Remove-ItemProperty -Path HKLM:\Software\Microsoft\Fusion -Name LogFailures
Remove-ItemProperty -Path HKLM:\Software\Microsoft\Fusion -Name LogResourceBinds
Remove-ItemProperty -Path HKLM:\Software\Microsoft\Fusion -Name LogPath
-
7
-
This answer is way more useful, I put it into my scripts last time. Now few months later, I came back here and saw the thread again. Remind me of how I use it last time.– cwhsuCommented Jul 12, 2020 at 9:14
Set the following registry value:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion!EnableLog] (DWORD) to 1
To disable, set to 0 or delete the value.
[edit ]:Save the following text to a file, e.g FusionEnableLog.reg, in Windows Registry Editor Format:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion]
"EnableLog"=dword:00000001
Then run the file from windows explorer and ignore the warning about possible damage.
-
4Not that the entry probably won't exist - you'll have to create it. At least, I did when I was about to answer this question just before the crash this morning :) Commented Nov 1, 2008 at 15:54
-
4What does the ! mean? Key or value? What about 64 bits systems? Commented Jul 14, 2009 at 15:21
-
2this doesn't actually work. the value is ForceLog not EnableLog, and there is an additional step needed here (see: thepursuitofalife.com/…)– MarchyCommented Nov 16, 2009 at 22:04
-
49actually, this does work...you just need to run iisreset afterwords to get it to work. Commented Jun 22, 2010 at 13:02
-
4@Norman: Because this particular setting is used to make the Asp.Net errors show assembly binding error messages in the error pages, not to save the logs to file. @OP: +1. Edited to include a .reg file. The ! format is one I had never seen, except in the error message that sent me to this page looking for answers.– BrianCommented Feb 8, 2011 at 21:53
There's so much wrong with the Assembly Binding Log Viewer (FUSLOGVW.exe) that I decided to write an alternative viewer named Fusion++ and put it on GitHub. It uses the same mechanics internally but parses the logs for you. You don't have to care for any settings at all, not even log paths 😉
You can get the latest release from here or via chocolatey (choco install fusionplusplus
).
I hope you and some of the visitors in here can save some worthy lifetime minutes with it.
The Fusion Log Settings Viewer changer script is bar none the best way to do this.
In ASP.NET, it has been tricky at times to get this to work correctly. This script works great and was listed on Scott Hanselman's Power Tool list as well. I've personally used it for years and its never let me down.
-
ps MAKE SURE you disable it after running or this folder could get quite large Commented Sep 19, 2012 at 0:32
-
this is why I use ETW, to only log data if I really need them, not all the time in an ugly large log file. Commented Apr 3, 2015 at 6:58
Instead of using a ugly log file, you can also activate Fusion log via ETW/xperf by turning on the DotnetRuntime Private provider (Microsoft-Windows-DotNETRuntimePrivate
) with GUID 763FD754-7086-4DFE-95EB-C01A46FAF4CA
and the FusionKeyword
keyword (0x4) on.
@echo off
echo Press a key when ready to start...
pause
echo .
echo ...Capturing...
echo .
"C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\xperf.exe" -on PROC_THREAD+LOADER+PROFILE -stackwalk Profile -buffersize 1024 -MaxFile 2048 -FileMode Circular -f Kernel.etl
"C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\xperf.exe" -start ClrSession -on Microsoft-Windows-DotNETRuntime:0x8118:0x5:'stack'+763FD754-7086-4DFE-95EB-C01A46FAF4CA:0x4:0x5 -f clr.etl -buffersize 1024
echo Press a key when you want to stop...
pause
pause
echo .
echo ...Stopping...
echo .
"C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\xperf.exe" -start ClrRundownSession -on Microsoft-Windows-DotNETRuntime:0x8118:0x5:'stack'+Microsoft-Windows-DotNETRuntimeRundown:0x118:0x5:'stack' -f clr_DCend.etl -buffersize 1024
timeout /t 15
set XPERF_CreateNGenPdbs=1
"C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\xperf.exe" -stop ClrSession ClrRundownSession
"C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\xperf.exe" -stop
"C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\xperf.exe" -merge kernel.etl clr.etl clr_DCend.etl Result.etl -compress
del kernel.etl
del clr.etl
del clr_DCend.etl
When you now open the ETL file in PerfView and look under the Events table, you can find the Fusion data:
-
@YuriBondarchuk this activates it on demand and you have more data in the ETL (other processes, fileversion data) so that you can give the files t other users and they can get MUCH more information compared to the normal fusion log Commented Sep 17, 2015 at 4:04
For those who are a bit lazy, I recommend running this as a bat file for when ever you want to enable it:
reg add "HKLM\Software\Microsoft\Fusion" /v EnableLog /t REG_DWORD /d 1 /f
reg add "HKLM\Software\Microsoft\Fusion" /v ForceLog /t REG_DWORD /d 1 /f
reg add "HKLM\Software\Microsoft\Fusion" /v LogFailures /t REG_DWORD /d 1 /f
reg add "HKLM\Software\Microsoft\Fusion" /v LogResourceBinds /t REG_DWORD /d 1 /f
reg add "HKLM\Software\Microsoft\Fusion" /v LogPath /t REG_SZ /d C:\FusionLog\
if not exist "C:\FusionLog\" mkdir C:\FusionLog
Just a tiny bit of info that might help others; if you do something along the lines of searching all assemblies in some directory for classes that inherit/implement classes/interfaces, then make sure you clean out stale assemblies if you get this error pertaining to one of your own assemblies.
The scenario would be something like:
- Assembly A loads all assemblies in some folder
- Assembly B in this folder is stale, but references assembly C
- Assembly C exists, but namespaces, class names or some other detail might have changed in the time that has passed since assembly B became stale (in my case a namespace was changed through a refactoring process)
In short: A ---loads--> B (stale) ---references---> C
If this happens, the only telltale sign is the namespace and classname in the error message. Examine it closely. If you can't find it anywhere in your solution, you are likely trying to load a stale assembly.
Just in case you're wondering about the location of FusionLog.exe - You know you have it, but you cannot find it? I was looking for FUSLOVW in last few years over and over again. After move to .NET 4.5 number of version of FUSION LOG has exploded. Her are places where it can be found on your disk, depending on software which you have installed:
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\x64
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin
This is not an answer but a word of warning:
- If you ever enable this logging, DO NOT FORGET TO DISABLE IT or you will regret it later.
I did forget, and I ended up with several GB of small log files with HTM
extension in C:\Windows\System32\config\systemprofile\AppData\Local\Microsoft\Windows\INetCache\IE
folder — it was apparently logging all assembly bindings from applications running under NT AUTHORITY\SYSTEM
account.
The number of files was greater than 3 million and neither Total Commander nor Windows Explorer could display the contents or folder size without hanging.
After disabling logging and a reboot for good measure, I ran the deletion from command prompt.
It took more than 15 minutes to delete all the files on a Samsung 970 Pro SSD which was showing 100% disk usage all the time — my high-end PC workstation was brought down to its knees by this delete operation and remained only partially responsive until it finished.
If you already have logging enabled and you still get this error on Windows 7 64 bit, try this in IIS 7.5:
Create a new application pool
Go to the Advanced Settings of this application pool
Set the Enable 32-Bit Application to True
Point your web application to use this new pool
In my case helped type disk name in lower case
Wrong - C:\someFolder
Correct - c:\someFolder
-
1
-
I used this as value for LogPath parameter in registry. But now I think the problem was not in CASE but in wrong letter C != С Commented Nov 24, 2021 at 14:55
fuslogvw.exe
as an administrator to avoid any rights issues.