背景:
我在问题行上放置了断点,清除了输出窗口,按F10,比较了我运行该行时的输出(将对象添加到ObservableCollection,其CollectionChanged处理程序具有加载非托管块的代码)
案例1:双击EXE ..完美运行(略微剪断)
'MyApp.DesktopApp.exe': Loaded 'D:\WordAutomation\MyApp_Source\Executables\MyApp\ManagedFrameworkWrapper.dll', Symbols loaded.
'MyApp.DesktopApp.exe': Loaded 'D:\WordAutomation\MyApp_Source\Executables\MyApp\Unmanaged.Framework.dll'
'MyApp.DesktopApp.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_597c3456\msvcr90d.dll', Symbols loaded.
'MyApp.DesktopApp.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_597c3456\msvcp90d.dll', Symbols loaded.
'MyApp.DesktopApp.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugMFC_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_2a62a75b\mfc90ud.dll', Symbols loaded.
'MyApp.DesktopApp.exe': Loaded 'C:\WINDOWS\system32\msimg32.dll'
'MyApp.DesktopApp.exe': Loaded 'D:\WordAutomation\MyApp_Source\Executables\MyApp\HelperFunctions.dll'
'MyApp.DesktopApp.exe': Loaded 'C:\WINDOWS\system32\dbghelp.dll'
'MyApp.DesktopApp.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_597c3456\msvcm90d.dll', Symbols loaded.
'MyApp.DesktopApp.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.MFCLOC_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_11f3ea3a\mfc90enu.dll', Binary was not built with debug information.
CCollectionDataType ConstCCollectionDataType ConstCCollectionDataType ConstCCollectionDataType ConstCCollectionDataType ConstCCollectionDataType Const'MyApp.DesktopApp.exe' (Managed): Loaded 'D:\WordAutomation\MyApp_Source\Executables\MyApp\ManagedFrameworkWrapper.dll', Symbols loaded.
'MyApp.DesktopApp.exe' (Managed): Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_597c3456\msvcm90d.dll', Symbols loaded.
The thread 'Win32 Thread' (0x12ec) has exited with code 0 (0x0).
案例2:运行相同的行,但是从Word代码隐藏的.cs文件中启动
A first chance exception of type 'System.IO.FileNotFoundException' occurred in WindowsBase.dll
The program '[5320] WINWORD.EXE: Managed' has exited with code 0 (0x0).
我试过了
我注意到Word似乎正在将托管引用程序集复制到一个位置,如下面的代码段所示..这可能是一个调查线。但为什么这样做是这样的,它如何解决非托管DLL ..我不知道。同样在第一个片段中,有一些DLL从WinSXS路径加载,也可能是另一个领导。
'WINWORD.EXE' (Managed): Loaded 'C:\Documents and Settings\pillaigi\Local Settings\Application Data\assembly\dl3\6HQYB5GK.LY0\KC4WN109.HT4\4d81c901\70abeb86_124ec901\MyWPFPlotPopup.DLL', Symbols loaded.
最后优雅地关闭......帮助!!
答案 0 :(得分:1)
要找出导致问题的dll以及查找dll的位置,请使用ProcessMon(不含sysinternals)。
请在此处查看我的回答: Referenced answer