2013-01-06 29 views
1

我想從C API使用C#代碼。 C API實際上可以從Java應用程序中獲得。從Java應用程序使用C API包裝器時出現異常

我創建了一個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目標文件」行。

我已經嘗試將我的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). 

回答

1

我找到了我的問題的解決方案,它原來是C++/CLI包裝器和C#dlls的位置。我必須在(appdirectory)/ jre/bin中找到dll。我在同一個目錄中看到一些微軟的dll後得出了這個結論。

+0

「appdirectory」是正在使用的JRE的路徑。例如:'C:\ Program Files(x86)\ Java \ jdk1.7.0_45 \'。把DLL放在'\ jre \ bin \'中。 – Josh

相關問題