Sign in to follow this  

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this