1

我正在尝试使用 C API 中的 C# 代码。C API 实际上可从 Java 应用程序中获得。

我创建了一个 C++/CLI 包装器来调用一个简单的 C# 函数,并使用一个简单的 C++ 控制台应用程序验证了它的工作原理。我还编写了 C++ dll,它可以与随 Java 程序发布的 C API 一起成功运行。尽管当我尝试使用同一个程序来调用 C++/CLI 包装器时,主机 Java 程序会立即退出而没有任何错误。然后我尝试实例化 C++/CLI 对象并在 try/catch 块中调用成员函数,但它仍然立即退出。这是我的代码:

try
{
CutLoggerGraphWrapper obj;
obj.SetRdoc(1.234);
}
catch (exception & e)
{
    AllocConsole();
    freopen("CONIN$", "r", stdin);
    freopen("CONOUT$", "w", stdout);
    freopen("CONOUT$", "w", stderr);
    cout << e.what() << endl;
    FreeConsole();
}

当我将 Visual Studio 中的调试会话附加到 Java 应用程序 (javaw.exe) 时,它会在“CutLoggerGraphWrapper obj”行出现故障。

我尝试将我的 dll 放置在多个位置,包括与 Java 应用程序 dll 位于同一文件夹中,然后放置在 PATH 环境变量中列出的文件夹中。我在想它可能没有加载包装器或 C# dll。这并没有改变什么。我无法从 Visual Studio 的输出中理解问题所在。这是来自输出窗口的消息。有什么建议么?

'javaw.exe' (Win32): Loaded 'C:\cgtech70\windows64\jre\bin\javaw.exe'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\advapi32.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\sechost.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\rpcrt4.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\user32.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\gdi32.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\lpk.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\usp10.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\imm32.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\msctf.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\nvinitx.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\cgtech70\windows64\jre\bin\server\jvm.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\winmm.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\cgtech70\windows64\jre\bin\hpi.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\psapi.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\cgtech70\windows64\jre\bin\verify.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\cgtech70\windows64\jre\bin\java.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\cgtech70\windows64\jre\bin\zip.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\cgtech70\windows64\jre\bin\awt.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\winspool.drv'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\ole32.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\shell32.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\shlwapi.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\uxtheme.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\cgtech70\windows64\jre\bin\fontmanager.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\dwmapi.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\cryptbase.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\apphelp.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\cgtech70\windows64\jre\bin\net.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\ws2_32.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\nsi.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\mswsock.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\wship6.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\cgtech70\windows64\jre\bin\nio.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\cgtech70\windows64\jre\bin\jpeg.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Program Files (x86)\DisplayFusion\Hooks\AppHookx64_678D2E40-CE87-49FD-B8A9-B7BDE75F14AB.dll'. Module was built without symbols.
'javaw.exe' (Win32): Loaded 'C:\Windows\winsxs\amd64_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.17514_none_a4d6a923711520a9\comctl32.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\clbcatq.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\oleaut32.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\cgtech70\windows64\vericut\CGTech.dll'. Module was built without symbols.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\wsock32.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\winsxs\amd64_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.6195_none_88e41e092fab0294\msvcr80.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\avifil32.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\msacm32.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\msvfw32.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\opengl32.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\glu32.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\ddraw.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\dciman32.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\setupapi.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\cfgmgr32.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\devobj.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\cgtech70\windows64\jre\bin\jawt.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\comdlg32.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\netapi32.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\netutils.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\srvcli.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\wkscli.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\WSHTCPIP.DLL'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\nlaapi.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\NapiNSP.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\pnrpnsp.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\dnsapi.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\winrnr.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\IPHLPAPI.DLL'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\winnsi.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\FWPUCLNT.DLL'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\rasadhlp.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\netbios.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\sspicli.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\cgtech70\windows64\jre\bin\dcpr.dll'. Cannot find or open the PDB file.
The thread 0x1688 has exited with code 0 (0x0).
First-chance exception at 0x0000000002C380E0 in javaw.exe: 0xC0000005: Access violation reading location 0x0000000000000028.
'javaw.exe' (Win32): Loaded 'C:\Dev\CutLogger\Build\Release\OptiAPI.dll'. Symbols loaded.
'javaw.exe' (Win32): Loaded 'C:\cgtech70\windows64\vericut\CutLoggerWrapper.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\mscoree.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\msvcr110d.dll'. Symbols loaded.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\msvcp110d.dll'. Symbols loaded.
'javaw.exe' (Win32): Loaded 'C:\cgtech70\windows64\vericut\opapi.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\msvcp110.dll'. Symbols loaded.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\msvcr110.dll'. Symbols loaded.
'javaw.exe' (Win32): Loaded 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscoreei.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\System32\msvcr110_clr0400.dll'. Cannot find or open the PDB file.
First-chance exception at 0x000007FEFD96A49D (KernelBase.dll) in javaw.exe: 0x04242420 (parameters: 0x0000000031415927, 0x000007FEE7E60000, 0x000000000C3FDD40).
'javaw.exe' (Win32): Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_64\mscorlib\9da5bb33cd1c34b7851c088f0cf749cc\mscorlib.ni.dll'. 
'javaw.exe' (Win32): Loaded 'C:\cgtech70\windows64\vericut\CutLoggerWrapper.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\cgtech70\windows64\vericut\CutLoggerWrapper.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Unloaded 'C:\cgtech70\windows64\vericut\CutLoggerWrapper.dll'
'javaw.exe' (Win32): Loaded 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clrjit.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\diasymreader.dll'. Cannot find or open the PDB file.
'javaw.exe' (Win32): Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_64\System\e3305bdbd03ef919051aa7f2783ac32a\System.ni.dll'. 
First-chance exception at 0x000007FEFD96A49D in javaw.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x000000000C3FA640.
First-chance exception at 0x000007FEFD96A49D in javaw.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
First-chance exception at 0x000007FEFD96A49D in javaw.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x000000000C3FA640.
First-chance exception at 0x000007FEFD96A49D in javaw.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
First-chance exception at 0x000007FEFD96A49D in javaw.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x000000000C3FA640.
First-chance exception at 0x000007FEFD96A49D (KernelBase.dll) in javaw.exe: 0xE0434352 (parameters: 0xFFFFFFFF80070002, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x000007FEE7E60000).
First-chance exception at 0x000007FEFD96A49D in javaw.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
First-chance exception at 0x000007FEFD96A49D (KernelBase.dll) in javaw.exe: 0xE0434352 (parameters: 0xFFFFFFFF80070002, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x000007FEE7E60000).
First-chance exception at 0x00000000083170A1 (jvm.dll) in javaw.exe: 0xC0000005: Access violation reading location 0x00000000E0000000.
First-chance exception at 0x00000000083170A1 (jvm.dll) in javaw.exe: 0xC0000005: Access violation reading location 0x00000000E0000000.
The thread 0x17ac has exited with code 1 (0x1).
The thread 0x1238 has exited with code 1 (0x1).
The thread 0xf7c has exited with code 1 (0x1).
The thread 0x9c0 has exited with code 1 (0x1).
The thread 0x1080 has exited with code 1 (0x1).
The thread 0x6c0 has exited with code 1 (0x1).
The thread 0xadc has exited with code 1 (0x1).
The thread 0xcb0 has exited with code 1 (0x1).
The thread 0x1704 has exited with code 1 (0x1).
The thread 0x178c has exited with code 1 (0x1).
The thread 0x1544 has exited with code 1 (0x1).
The thread 0x1254 has exited with code 1 (0x1).
The thread 0xf0 has exited with code 1 (0x1).
The thread 0x16bc has exited with code 1 (0x1).
The thread 0x510 has exited with code 1 (0x1).
The thread 0xc44 has exited with code 1 (0x1).
The thread 0x44c has exited with code 1 (0x1).
The thread 0x15c8 has exited with code 1 (0x1).
The thread 0x1154 has exited with code 1 (0x1).
The thread 0x7fc has exited with code 1 (0x1).
The thread 0xd8c has exited with code 1 (0x1).
The thread 0xee4 has exited with code 1 (0x1).
The thread 0x165c has exited with code 1 (0x1).
The thread 0xaa8 has exited with code 1 (0x1).
The thread 0x9c4 has exited with code 1 (0x1).
The thread 0x15b0 has exited with code 1 (0x1).
The thread 0x16fc has exited with code 1 (0x1).
The thread 0x141c has exited with code 1 (0x1).
The thread 0xec0 has exited with code 1 (0x1).
The thread 0x13d0 has exited with code 1 (0x1).
The thread 0x17e8 has exited with code 1 (0x1).
The thread 0xd44 has exited with code 1 (0x1).
The thread 0x1630 has exited with code 1 (0x1).
The thread 0x1204 has exited with code 1 (0x1).
The thread 0x7f8 has exited with code 1 (0x1).
The thread 0x14ac has exited with code 1 (0x1).
The thread 0x1340 has exited with code 1 (0x1).
The thread 0x428 has exited with code 1 (0x1).
The thread 0x5ec has exited with code 1 (0x1).
The program '[4796] javaw.exe' has exited with code 1 (0x1).
4

1 回答 1

1

我找到了解决问题的方法,原来是 C++/CLI 包装器和 C# dll 的位置。我必须在 (appdirectory)/jre/bin 中找到 dll。在看到同一目录中的一些 microsoft dll 后,我得出了这个结论。

于 2013-01-08T15:36:09.643 回答