Bagaimana cara mengaktifkan pencatatan kegagalan pengikatan perakitan (Fusion) di .NET?
Tambahkan nilai berikut ke
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion Tambahkan: DWORD ForceLog setel nilai ke 1 DWORD LogFailures setel nilai ke 1 DWORD LogResourceBinds setel nilai ke 1 DWORD EnableLog setel nilai ke 1 String LogPath set value ke folder untuk log (misalnya C:\FusionLog\)
Pastikan Anda mencantumkan backslash setelah nama folder dan Folder tersebut ada.
Anda perlu memulai ulang program yang Anda jalankan untuk memaksanya membaca pengaturan registri tersebut.
BTW, jangan lupa untuk mematikan fusion logging off ketika tidak diperlukan.
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:
c:\FusionLogs
(Important: make sure that you have actually created this folder in the file system.)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.)
Jika Anda memiliki Windows SDK yang terinstal di mesin Anda, Anda akan menemukan "Fusion Log Viewer" di bawah Microsoft SDK\Tools (cukup ketik "Fusion" di menu start pada Vista atau Windows 7/8). Luncurkan, klik tombol Settings, dan pilih "Log bind failure" atau "Log all binds".
Jika tombol-tombol ini dinonaktifkan, kembali ke menu start, klik kanan Log Viewer, dan pilih "Run as Administrator".
Tetapkan nilai registri berikut ini:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion!EnableLog] (DWORD) ke 1
Untuk menonaktifkan, atur ke 0 atau hapus nilainya.
[edit]: Simpan teks berikut ke file, misalnya FusionEnableLog.reg, di Format Editor Registri Windows:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion]
"EnableLog"=dword:00000001
Kemudian jalankan file tersebut dari windows explorer dan abaikan peringatan tentang kemungkinan kerusakan.
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
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.
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:
I wrote an assembly binding log viewer named Fusion++ and put it on GitHub.
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.
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:
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.
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
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
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