求助C#调用C++方法的参数转换
static array<byte> ^ compress(array<byte> ^source)//C++ 方法方法名参数
[DllImport(@"lzma_decode_module.dll", EntryPoint = "compress")]
public static extern byte[] compress([MarshalAs(UnmanagedType.LPArray)]byte[] _b);
报错:Cannot marshal 'return value': Invalid managed/unmanaged type combination.
貌似是[MarshalAs(UnmanagedType.LPArray) 这没用对? 我用UnmanagedType.SafeArray和ByValArray都是这个错。。。
应该怎么调用啊???
以前没怎么用用过C++DLL。求助。。
[解决办法]
托管引入的话,直接可以用的啊
[解决办法]
[DllImport(@"lzma_decode_module.dll", EntryPoint = "compress")]
public static extern byte[] compress(byte[] _b);
C++/CLI MarshalAs 做啥,这二者数据类型是一致的。只要从dll导入即可。
[解决办法]
直接用就行了, 跟用C#方法一样的用。