DLL导出数组引用C# [英] DLL export array reference to C#

查看:54
本文介绍了DLL导出数组引用C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将c#中的字符串数组传递给c ++并操纵该数组的数据。我怎样才能做到这一点? (我是c ++ newb)


c ++

展开 | 选择 | Wrap < span class =codeDivider> | 行号

解决方案

< blockquote>

展开 | 选择 | Wrap | 行号


感谢您的帖子,只是试一试,但仍然得到相同的结果:(


你确定一个String数组与LPCTSTR相同吗?


我怀疑互操作性规则导致了这一点。


我使用互操作性msdn字符串进行了Google高级搜索。并获得了很多热门歌曲。其中一个人说:


默认情况下,.NET字符串由COM Interop编写到C ++中的LPTSTR,反之亦然,所以你必须使用MarshalAs属性显式地将任何其他类型的非托管字符串(包括BSTR)编组到.NET字符串中。


继承IUnknown或IDispatch没有特别的问题但是如果从后者继承,则必须使用InterfaceType属性标记C#接口声明。



我留给你研究这个。


I am trying to pass a string array from c# into c++ and manipulate the data of that array. How can I do this? (I am c++ newb)

c++

Expand|Select|Wrap|Line Numbers

解决方案

Expand|Select|Wrap|Line Numbers


Thanks for the post, just gave it a try but still getting the same results :(


Are you sure a String array is the same as an LPCTSTR?

I suspect interoperability rules are causing this.

I did a Google advanced search using "interoperability msdn String" and got a lot of hits. One of them said:

By default, .NET strings are marshalled by COM Interop to LPTSTR in C++ and, vice versa, and so you have to explicitly marshal any other type of unmanaged string (including BSTR) to and from a .NET string using the MarshalAs attribute.

There''s no particular problem in inheriting from IUnknown or IDispatch but, if you inherit from the latter, you have to mark the C# interface declaration with the InterfaceType attribute.

I am leaving it to you to research this.


这篇关于DLL导出数组引用C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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