Why does the dll produce ” An unhandled exception of type 'System.StackOverflowException' occurred i

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello everyone,
I am using a thid party and unfortunately badly documented dll like this:[DllImport("mydll.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
private static extern uint ulExtendedAccess(StringBuilder Command, StringBuilder ReturnBuffer, ushort BUFFER_LENGTH , out StatusLV LV, out StatusVB VB, byte noidea );
and whenever I am using the function uiExtendedAccess(), my application crashes with the error: "An unhandled exception of the type System.StackoverflowException occurred in Unknown Module.".
I only have a C++ wrapperfile which is showing the structures of StatusLV and StatusVB and from my experiments with several structures, it looks like I am having doing soimething wrong in interpreting the following lines:typedef struct
{... // some more definitions are here //
char acString1[ARRAY_SIZE];
char acString2[ARRAY_SIZE];
double afV[ARRAY_SIZE];
char acPName[PLATFORM_NAME_LEN];
char acPList[MAX_PLATFORM_COUNT * PLATFORM_NAME_LEN];
}StatusVB
which I have converted into C#:[StructLayout(LayoutKind.Sequential)]
public struct StatusVB
{... // hopefully correctly transformed before this //
public char[] acString1;
public char[] acString2;
public double[] afV;
public char[] acPName;
public char[] acPList;
}
and typedef struct
{ ... // some more definitions here which I think are correct //
THandle VArray;
LHandle DName;
LHandle Name;
}StatusLV;
which I have transferred to C# like this:[StructLayout(LayoutKind.Sequential)]
public struct StatusLV
{
public THandle VArray; // THandle
public LHandle DName; // LHandle
public LHandle Name; // LHandle
}
Boith, LHandle and THandle are structures themselves and they are defined as:typedef struct
{
long dimSize;
double Numeric[DEF_ARRAY_SIZE];
}sVV;
typedef sVV **THandle;
typedef struct
{
int cnt;
char str[DEF_ARRAY_SIZE];
}strString;
typedef strString **LHandle;
which I have transferred into C# like thispublic struct LHandle
{
public int cnt;
public char[] str;
}
public struct THandle
{
long dimSize;
double[] Numeric;
}
Does anyone have an idea?
Benjamin
Info im http://social.msdn.microsoft.com/Forums/en-US/user

View the full article
 
Back
Top