Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过c+从java调用c#dll时出错+;包装纸_C#_Java_C++_Wrapper - Fatal编程技术网

通过c+从java调用c#dll时出错+;包装纸

通过c+从java调用c#dll时出错+;包装纸,c#,java,c++,wrapper,C#,Java,C++,Wrapper,首先,这是我的配置: 我在一台64位的Win7电脑上工作,在虚拟机上还有一台XP 32位的SP3。 我使用VisualStudio2010和eclipse 我正在使用以下组件: BusinessDll:我希望java能够访问的C#dll(32位.NET framework 3.5) 强>包装器< /强>:C++ 32 DLL,用于将java调用转发到C语言。它引用了c#dll 强>包装测试调用包装函数的C++测试exe。< /LI> Java组件:使用jre7 32位的测试项目 我想使用ja

首先,这是我的配置: 我在一台64位的Win7电脑上工作,在虚拟机上还有一台XP 32位的SP3。 我使用VisualStudio2010和eclipse

我正在使用以下组件:

  • BusinessDll:我希望java能够访问的C#dll(32位.NET framework 3.5)
  • 强>包装器< /强>:C++ 32 DLL,用于将java调用转发到C语言。它引用了c#dll 强>包装测试<强>调用包装函数的C++测试exe。< /LI>
  • Java组件:使用jre7 32位的测试项目
<>我想使用java组件的BuffDLL,所以我决定在JC++中使用JNA和包装器。 下面是我所做的调用测试:

  • 包装测试->包装->业务DLL-->OK

  • Java组件->包装器-->确定

  • Java组件->包装器->业务DLL-->KO
我谨此致辞:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (0xe0434352), pid=264, tid=6488
#
# JRE version: 7.0_25-b16
# Java VM: Java HotSpot(TM) Client VM (23.25-b01 mixed mode windows-x86 )
# Problematic frame:
# C  [KERNELBASE.dll+0xc41f]  RaiseException+0x58
崩溃堆栈:

Stack: [0x00810000,0x00860000],  sp=0x0085e13c,  free space=312k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [KERNELBASE.dll+0xc41f]  RaiseException+0x58
C  [clr.dll+0xe2b54]  GetCLRFunction+0xd209
C  [clr.dll+0x12849b]  CopyPDBs+0x4ab5
C  [clr.dll+0x2ccacd]  CorLaunchApplication+0x255e5
我在Win7 64位和XP 32位虚拟机上得到了相同的结果

下面是我使用的代码:

Java组件

System.load("D:\\dev\\Wrapper.dll");
public interface BioWrapp extends Library 
{
    Wrapp INSTANCE = (Wrapp) Native.loadLibrary("Wrapper", Wrapp.class);
    void SuperDummy();
}
public static void main(String[] args)
{
    BioWrapp mysdll = BioWrapp.INSTANCE;
    mysdll.BioSuperDummy();
}
包装器

JavaInterface.h

#ifdef BIOWRAPPDLL_EXPORTS
#define BIOWRAPPDLL_API __declspec(dllexport) 
#else
#define BIOWRAPPDLL_API __declspec(dllimport) 
#endif

namespace BioJavaWrapperNp
{
    class BioJavaWrapper
    {
    public: 
        static BIOWRAPPDLL_API void BioSuperDummy(); 
    };
}
#ifdef __cplusplus
extern "C"
{
#endif
    __declspec(dllexport)  void superDummy( );
#ifdef __cplusplus
}
#endif
DotNetInterface.h

#ifdef BIOWRAPPDLL_EXPORTS
#define BIOWRAPPDLL_API __declspec(dllexport) 
#else
#define BIOWRAPPDLL_API __declspec(dllimport) 
#endif

namespace BioJavaWrapperNp
{
    class BioJavaWrapper
    {
    public: 
        static BIOWRAPPDLL_API void BioSuperDummy(); 
    };
}
#ifdef __cplusplus
extern "C"
{
#endif
    __declspec(dllexport)  void superDummy( );
#ifdef __cplusplus
}
#endif
包装器

#include "stdafx.h"
#include "BioJavaWrapper.h"

using namespace System;
using namespace System::Runtime::InteropServices;
using namespace BioBusiness;

namespace BioBusinessNp
{
    void BioJavaWrapper::BioSuperDummy()
    {
        BusinessClass::superDummy();
    }
}
在C#dll中使用BioBusiness命名空间的BusinessClass部分。超级虚拟是一种生物商业方法

我已经试了几天了,欢迎有任何想法。 谢谢你的阅读


<阿德里安> /p> < p>你的C++ DLL是用托管C++编写的,我加倍,这就是你得到这个异常的原因。我想你可以试试这个: 1.在本地C++中编写包装DLL,它将调用混合C++ DLL中的函数,然后混合C++将调用C语言中的函数 2.在本地C++中编写包装器DLL,并将C语言作为一个COM导出,然后在本地C++中使用这个COM组件。 还有一件事:内部错误(0xe0434352)。0xe0434352表示CLR生成的此异常。您可以使用Windbg获取异常的详细信息。请看这个