# [.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.

## 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 on other sites
You might find some info here

Cheers

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633297
• Total Posts
3011247
• ### Who's Online (See full list)

There are no registered users currently online

×