• Advertisement
Sign in to follow this  

[.net] P/Invoke with complex (CORBA) structures

This topic is 4607 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I'm trying to call a C function in a DLL from C# code. The function looks like this:
extern "C"  tRetcode __declspec(dllexport) GetTest(tTestStructure& input);
The tTestStructure is a quite complex structure generated from an CORBA idl, having arrays of structures as members, that can have complex members themselves. My problem now is that I get a System.Runtime.InteropServices.COMException when I try to call that function. My prototype looks like this:
public static extern tRetcode GetTest(ref tTestStructure input);
I tried different levels of complexity for the tTestStructure to try to find what caused the exception exactly. So far I only think that there is a problem with a structure array within the tTestStructure is inited. Assume
public struct tTestStructure
    public tAnotherStructure[] child;
If I just tTestStructure bla = new tTestStructure(); and pass it to the function then there is no problem, the function is called just fine. But if I do bla.child = new tAnotherStrucure[10]; then the call does not go through. Did I do something wrong here? What should I do? What things do I have to be aware of? Thanks for your answers!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement