在 C++ 中使用 C# COM 包装的 DLL 会抛出未注册的类

using c# com wrapped dll in c++ throws class not registered

本文关键字:DLL 注册 包装 C++ COM      更新时间:2023-10-16

当我尝试使用 CreateInstance 调用实例化由 com 包装的 c# dll 时,我收到"类未注册"异常。

以下是堆栈跟踪:

'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64ntdll.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64kernel32.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64KernelBase.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64ole32.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64msvcrt.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64gdi32.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64user32.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64advapi32.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64sechost.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64rpcrt4.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64sspicli.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64cryptbase.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64lpk.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64usp10.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64oleaut32.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64msvcr110d.dll'. Symbols loaded.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64msvcp110d.dll'. Symbols loaded.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64imm32.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64msctf.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64uxtheme.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:Program Files (x86)FlashGetfgmgr.dll'. Module was built without symbols.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64comdlg32.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64shlwapi.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:Windowswinsxsx86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.17514_none_ec83dffa859149afcomctl32.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64shell32.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64version.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64wininet.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64normaliz.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64iertutil.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64urlmon.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64clbcatq.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64mscoree.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsMicrosoft.NETFrameworkv4.0.30319mscoreei.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64sxs.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsMicrosoft.NETFrameworkv2.0.50727mscorwks.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:Windowswinsxsx86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.6195_none_d09154e044272b9amsvcr80.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsSysWOW64profapi.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Loaded 'C:WindowsassemblyNativeImages_v2.0.50727_32mscorlibacfc1391e45fedd2a359778ea57d914cmscorlib.ni.dll'. 
'Test.exe' (Win32): Loaded 'C:WindowsMicrosoft.NETFrameworkv2.0.50727Culture.dll'. Cannot find or open the PDB file.
'Test.exe' (Win32): Unloaded 'C:WindowsMicrosoft.NETFrameworkv2.0.50727Culture.dll'
First-chance exception at 0x75E7B9BC in Test.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x004BDACC.
First-chance exception at 0x75E7B9BC in Test.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
First-chance exception at 0x75E7B9BC in Test.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
First-chance exception at 0x75E7B9BC in Test.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.

好吧,C# COM 类未注册。使用 RegAsm.exe 注册 C# COM DLL。