J
Jeff Lederer
I have created a simple test C# console program that calls an unmanaged C
subroutine in a DLL where one of the arguments is a callback to the C# code.
I noticed that when the callback has no paramaters, it works fine. But when
there are parameters, I get the exception: "Runtime failure check #0: The
value of ESP not properly saved..."
Here are the facts: The delegate declaration:
The signature of the Pinvoke method:
The callback method:
public static int FindTrace(IntPtr pEnv, string logicalName)
{
return logicalName.CompareTo("wtrace")==0 ? 1 : 0;
}
the function call within the C# program:
The declaration of the the function call setting up the callback:
And the unmanaged call to the callback function inside the c routine:
where:
void *theEnv;
char *logicalName;
Using the debugger, I saw that the arguments are passed from the unmanaged
code to the callback routine correctly.
I am using version 1.0 of the IDE. Is this a bug in the CLR?
PS This is not my only example, I have other calls with similar problems.
subroutine in a DLL where one of the arguments is a callback to the C# code.
I noticed that when the callback has no paramaters, it works fine. But when
there are parameters, I get the exception: "Runtime failure check #0: The
value of ESP not properly saved..."
Here are the facts: The delegate declaration:
The signature of the Pinvoke method:
[DllImport("Clips.DLL", CharSet=CharSet.Ansi)]
public static extern bool EnvAddRouter(querydlg queryFunction);
The callback method:
public static int FindTrace(IntPtr pEnv, string logicalName)
{
return logicalName.CompareTo("wtrace")==0 ? 1 : 0;
}
the function call within the C# program:
The declaration of the the function call setting up the callback:
And the unmanaged call to the callback function inside the c routine:
where:
void *theEnv;
char *logicalName;
Using the debugger, I saw that the arguments are passed from the unmanaged
code to the callback routine correctly.
I am using version 1.0 of the IDE. Is this a bug in the CLR?
PS This is not my only example, I have other calls with similar problems.