首页 新闻 会员 周边

关于调用com组件的问题

0
悬赏园豆:50 [已关闭问题]

com组件名称 s.dll

包含方法签名如下

int CreateKey(char* dkey, int dkeyLen, char* ekey, int ekeyLen);

c#这样调用

[DllImport( "s.dll" , EntryPoint="CreateKey" ,CharSet = CharSet.Ansi)]
public static extern int CreateKey(out string decryptKey , int decryptKeyLen ,out string encryptKey , int encryptKeyLen );

调用代码如下:

string dkey = "";
string ekey = "";
int dlen = 32;
int elen = 32;
CreateKey(out dkey, dlen, out ekey, elen);

 

看起来似乎正确,调用的时候确报如下错误

Additional Information: The runtime has encountered a fatal error. The address of the error was at 0x79e71bd7, on thread 0x7b0. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

郁闷...

问题补充: 早上都在忙什么呢?
老烟枪的主页 老烟枪 | 初学一级 | 园豆:15
提问于:2008-09-24 08:58
< >
分享
其他回答(1)
0

深刻的我看不出问题,只从肤浅的角度说,记得从前我做类似调用的时,string 类型尽量用 stringbuider 代替的。大概跟你说的不是一个问题了:)

陛下 | 园豆:3938 (老鸟四级) | 2008-09-24 09:37
0

把dll传上来看看

zjy | 园豆:3194 (老鸟四级) | 2008-09-24 15:19
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册