Why do C# and VB.NET implicitly marshal char* differently?

前端 未结 3 1756
盖世英雄少女心
盖世英雄少女心 2021-02-20 16:19

So I have a function, written in C++, that looks like this...

extern \"C\" __declspec(dllexport) int __stdcall SomeFunction(char *theData)
{
    // stuff
}
         


        
3条回答
  •  青春惊慌失措
    2021-02-20 16:55

    Because they are different languages. VB.NET can a great deal of things that C# cannot for many reasons. I don't see the problem to be honest.

    I should add you could have simply did ref char[] and it would have worked. One problem I see is that your calling conventions do not match.

    So that also is likely the reason you got a memory exception error.

提交回复
热议问题