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

Started by
0 comments, last by ernow 18 years, 7 months ago
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!

------------------------------

There are only 10 kinds of people: those that understand binary and those that don't.

Advertisement
You might find some info here

Cheers

This topic is closed to new replies.

Advertisement