将引用C ++ DLL添加到C#但函数参数不正确 [英] Add references C++ DLL to C# but function argument is incorrect

查看:85
本文介绍了将引用C ++ DLL添加到C#但函数参数不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有.dll由C ++开发。

我有简单的功能链接。

Hi
I have .dll which developed by C++.
I have simple function linkw this.

Get_struct_data(struct_def *def, long* size)



* def struct_def 的数组。





使用'Add Reference ..'将.dll添加到C#项目之后。

C#的接口是


*def is array of struct_def.


After I added .dll to C# project by using 'Add Reference..'.
The interfaces for C# is

Get_struct_data(out struct_def def, out long size)





但我希望



But I expect

Get_struct_data(out struct_def def[], out long size)





这让我无法使用来自dll的功能。

有谁知道如何解决这个问题?





感谢Advances。



我尝试了什么:



我在Google上查了一天但没有看到有人在谈论thins。



This make me can't use function from dll.
Is any one know how can I fix this?


Thank in Advances.

What I have tried:

I did check on Google for a day but not see anyone talking about thins.

推荐答案

使用Richards链接中描述的编组。一个qucick解决方案通常只使用整数和字符串等集成数据类型来创建一个简单的数据接口。



在运行时分配结构和所有数据,以便每次都使用本地副本。



我在文章中提供了一些工作代码,我写这篇文章是为了帮助解决这个问题。问题。
Use the marshalling as described in Richards link. A qucick solution is often to make a plain data interface with only using integrated data types like integers and strings.

Allocate the struct and all data in the runtime where you want to use it, so make everytime a local copy.

I have some working code provided in an article I wrote to help on such questions.


请参阅如何to:Marshal Structures使用PInvoke [ ^ ]


这篇关于将引用C ++ DLL添加到C#但函数参数不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆