bbembi_de
11/23/2007 2:37:00 PM
Hello everyone,
I have a C# console application.
I use DllImport to access a c++ dll.
In an extra thread I poll a method in this dll.
This works fine.
Now the problem:
I use the same code and put it in the simplest windows forms
application and then the application crashes.
I get an StackOverflowException in my c++ dll.
How can that be?
I run this in an extra thread in loop every 500 ms:
VCIStruct vci = new VCIStruct();
int retCode = GetSelectedVCI(1, ref vci);
//.... use vci struct
retCode = DeleteVCIStruct(ref vci);
Dllimport definitions:
[DllImport("notMyDll.dll", ExactSpelling=true)]
public static extern int GetSelectedVCI(int channel, ref VCIStruct
vciStruct);
[DllImport("ToolkitApiDll.dll", ExactSpelling=true)]
public static extern int DeleteVCIStruct( ref VCIStruct pStruct);
Vci struct definition:
[StructLayout(LayoutKind.Sequential)]
public struct VCIStruct {
[MarshalAs(UnmanagedType.LPStr)] public string name;
public int medium;
[MarshalAs(UnmanagedType.LPStr)] public string serial;
//......
}
Any idea?
bye
juergen