Jump to content
  • Advertisement
Sign in to follow this  
grbrg

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

This topic is 4815 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:
[DllImport("some.dll")]
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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!