Troubleshooting: Cannot find referenced unmanaged dll when invoking custom code using Word code

Context:

  • I have a WPF application that uses certain unmanaged DLLs in the D: \ WordAutomation \ MyApp_Source \ Executables \ MyApp folder. I can double click the EXE and everything works.
  • Then I have a 2007 Word project that links to the appropriate managed DLLs in the above folder and tries to do the same. Bring up the app interface. After an adequate wave, I get my user interface. But now there is a user action that causes one of the unmanaged DLLs to be loaded, which sequentially explodes with a FileNotFoundException (no help / indication of which file is missing).

I put a breakpoint on the problematic line, cleared the output window, hit F10, compared the output when I ran this line (adding an object to the ObservableCollection whose CollectionChanged checkcode has a code that loads the unmanaged part)

Case 1: Double click the EXE .. which works fine (slightly cut off)

'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).

      

Case 2: Run the same line but run from a .cs file with Word code

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).

      

I tried

  • adding unmanaged DLLs to the same folder as (doc doc + VSTO)
  • added folder to PATH Environment variable . Still the same.
  • everything I could think of .. for the last few days

I notice that Word seems to copy the assembled ref assemblies to the location as shown below in the code snippet. This could be a consequence. But why does the word do it and how does it resolve unmanaged DLLs. I dont know. Also in the first snippet there are some DLLs loaded from the WinSXS path, which might be different as well.

'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.

      

Finally, to close gracefully ... Help!

0


source to share


1 answer


To find out which DLL is causing the problem and where the dll is looking for, use ProcessMon (no sysinternals).



See my answer here: Request response

+1


source







All Articles