开发者

How to return a byte[] to C# in C++ CLR

开发者 https://www.devze.com 2023-04-11 16:23 出处:网络
I\'m us开发者_C百科ing C++ CLR to wrap a native C++ dll. So that the C++ CLR dll can be accessed by a C# project.

I'm us开发者_C百科ing C++ CLR to wrap a native C++ dll. So that the C++ CLR dll can be accessed by a C# project.

The problem is that when I want to return a byte[] to C#, and write such code in CLR:

static System::Byte[]^ GetTestByteBuffer()
{
    System::Byte[]^ byte = gcnew System::Byte[128];
    return byte;
}

but it cannot pass compilation. Anyone can help me?

compilation error:

error C3409: empty attribute block is not allowed 
error C3409: empty attribute block is not allowed error C2146: syntax error "^": 
error C2334: unexpected token(s) preceding '{'; skipping apparent function


This is the way you declare a byte array in C++/CLI:

array<System::Byte>^

Google is your friend...

0

精彩评论

暂无评论...
验证码 换一张
取 消