我如何在.NET中启用程序集绑定失败日志记录(融合)?
当前回答
我通常使用Fusion日志查看器(从Visual Studio命令提示符或从开始菜单中的Fusion日志查看器中的Fuslogvw.exe) -我的标准设置是:
以管理员身份打开Fusion Log Viewer 点击设置 选中“启用自定义日志路径”复选框 输入要写入日志的位置,例如c:\FusionLogs(注意:请确保您已经在文件系统中创建了此文件夹)。 确保打开了正确的日志级别(我有时只是选择“日志全部绑定到磁盘”,只是为了确保事情正常工作) 单击OK 将日志位置选项设置为自定义
一旦你完成了,记得关闭登录!
(我刚刚就一个类似的问题发表了这篇文章——我认为这也与此相关。)
其他回答
设置以下注册表值:
(微软HKEY_LOCAL_MACHINE \ SOFTWARE \ \融合!EnableLog] (DWORD)到1
若要禁用,请设置为0或删除该值。
[edit]:将以下文本保存为文件,如“FusionEnableLog”。注册, Windows注册表编辑器格式:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion]
"EnableLog"=dword:00000001
然后从windows资源管理器运行该文件,并忽略有关可能损坏的警告。
将下列值添加到
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\)
确保在文件夹名称后包含反斜杠,并且文件夹存在。
您需要重新启动正在运行的程序,以强制它读取这些注册表设置。
顺便说一下,不要忘记在不需要的时候关闭融合日志记录。
您可以以管理员身份运行此Powershell脚本来启用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
这个要禁用:
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
您也可以通过ETW/xperf通过GUID 763FD754-7086-4DFE-95EB-C01A46FAF4CA和FusionKeyword关键字(0x4)打开dotnetruntimeprivate提供者(Microsoft-Windows-DotNETRuntimePrivate)来激活Fusion日志。
@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
当你现在在PerfView中打开ETL文件并在事件表下查看时,你可以找到Fusion数据:
如果你已经启用了日志记录,在Windows 7 64位上仍然会得到这个错误,在iis7.5中尝试一下:
创建一个新的应用程序池 进入该应用池的高级设置 将启用32位应用程序设置为True 让您的web应用程序使用这个新池
推荐文章
- _ViewStart的位置和方式。CSHTML布局文件链接?
- 新建T()
- 如何将枚举绑定到WPF中的组合框控件?
- 拒绝访问该路径
- Visual Studio - Resx文件默认“内部”为“公共”
- 使用linq转换列表到字典,不用担心重复
- 单元测试:日期时间。现在
- 什么是回调?
- .NET中的KeyDown和KeyPress有什么区别?
- 返回匿名类型的结果?
- 你能解释一下流的概念吗?
- 何时使用IList,何时使用List
- ConfigurationManager。AppSettings在.NET Core 2.0中可用?
- 在c#的控制台应用程序中使用'async
- 在单元测试中设置HttpContext.Current.Session