Click here to Skip to main content
15,890,438 members
Home / Discussions / C#
   

C#

 
GeneralRe: AxHost Pin
Heath Stewart27-Apr-04 3:26
protectorHeath Stewart27-Apr-04 3:26 
Generallist all machines on local domain with c# Pin
doph27-Apr-04 0:48
doph27-Apr-04 0:48 
GeneralRe: list all machines on local domain with c# Pin
Heath Stewart27-Apr-04 3:34
protectorHeath Stewart27-Apr-04 3:34 
GeneralFunny Exception Pin
sreejith ss nair27-Apr-04 0:45
sreejith ss nair27-Apr-04 0:45 
GeneralRe: Funny Exception Pin
Mike Dimmick27-Apr-04 0:55
Mike Dimmick27-Apr-04 0:55 
GeneralRe: Funny Exception Pin
Colin Angus Mackay27-Apr-04 1:42
Colin Angus Mackay27-Apr-04 1:42 
GeneralRe: Funny Exception Pin
Heath Stewart27-Apr-04 3:50
protectorHeath Stewart27-Apr-04 3:50 
GeneralCalling an exported Function - Issue with different calling convention in C# Pin
Vini Deep27-Apr-04 0:21
Vini Deep27-Apr-04 0:21 
Hi,

I have 2 methods exported from a dll, MyReader.dll

typedef unsigned short  UINT16;
typedef unsigned int UINT32;
typedef unsigned char   UINT8;
#define  CMYREADER_API   __declspec(dllexport)
 

class CMYREADER_API CMyReader 
{
 public:
      bool mapImage(UINT16 SectorSize, const char * FileOnHardDriveToMap);
      bool mapImage(UINT16 SectorSize, bool (* CallbackFunctionAddress)(UINT32 SectorToBeRead, UINT8 * SetToSectorData, bool IsLiteral));
....
};

How can I call the 2nd method from My C# Client? I have declared a delegate to pass as the 2nd argument to the function.
[DllImport("MyReader.dll", EntryPoint ="?mapImage@CMYReader@@QAE_NGP6A_NIPAE_N@Z@Z",CallingConvention=CallingConvention.ThisCall)]
private static extern System.Int32 mapImage(IntPtr inst,System.UInt16 SectorSize, ReadSectorDelegate CallbackFunctionAddress);

But when I give the CallingConvention as CallingConvention.ThisCall, I get the following error.
---------------------------<br />
Microsoft Visual C++ Debug Library<br />
---------------------------<br />
Debug Error!<br />
<br />
Program: E:\Vini\MyRdrTest\bin\Debug\MyRdrTest.exe<br />
Module: <br />
File: i386\chkesp.c<br />
Line: 42<br />
The value of ESP was not properly saved across a function call.  This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention. <br />
<br />
(Press Retry to debug the application)<br />
---------------------------<br />
Abort   Retry   Ignore   <br />
---------------------------

But if I change the callingConvention to CallingConvention.StdCall, it does not call the CallBack function. Is there any other way to implement this? What am I doing wrong here?

Kindly help.



Vini
GeneralRe: Calling an exported Function - Issue with different calling convention in C# Pin
Mike Dimmick27-Apr-04 0:57
Mike Dimmick27-Apr-04 0:57 
GeneralRe: Calling an exported Function - Issue with different calling convention in C# Pin
Heath Stewart27-Apr-04 3:53
protectorHeath Stewart27-Apr-04 3:53 
GeneralRe: Calling an exported Function - Issue with different calling convention in C# Pin
Heath Stewart27-Apr-04 4:03
protectorHeath Stewart27-Apr-04 4:03 
GeneralRe: Calling an exported Function - Issue with different calling convention in C# Pin
Vini Deep27-Apr-04 23:53
Vini Deep27-Apr-04 23:53 
GeneralRe: Calling an exported Function - Issue with different calling convention in C# Pin
Heath Stewart28-Apr-04 11:22
protectorHeath Stewart28-Apr-04 11:22 
GeneralRe: Calling an exported Function - Issue with different calling convention in C# Pin
Vini Deep29-Apr-04 2:23
Vini Deep29-Apr-04 2:23 
Generalexception in system.drawing.dll Pin
Member 69108927-Apr-04 0:14
Member 69108927-Apr-04 0:14 
GeneralRe: exception in system.drawing.dll Pin
Heath Stewart27-Apr-04 4:06
protectorHeath Stewart27-Apr-04 4:06 
QuestionHow to lunch htm through C# code Pin
Alex Getman26-Apr-04 21:40
Alex Getman26-Apr-04 21:40 
AnswerRe: How to lunch htm through C# code Pin
Kannan Kalyanaraman26-Apr-04 22:50
Kannan Kalyanaraman26-Apr-04 22:50 
AnswerRe: How to lunch htm through C# code Pin
Mike Dimmick26-Apr-04 23:34
Mike Dimmick26-Apr-04 23:34 
GeneralRe: How to lunch htm through C# code Pin
Alex Getman27-Apr-04 0:47
Alex Getman27-Apr-04 0:47 
GeneralRe: How to lunch htm through C# code Pin
Heath Stewart27-Apr-04 4:11
protectorHeath Stewart27-Apr-04 4:11 
GeneralRe: How to lunch htm through C# code Pin
Alex Getman27-Apr-04 4:23
Alex Getman27-Apr-04 4:23 
GeneralRe: How to lunch htm through C# code Pin
Heath Stewart27-Apr-04 5:30
protectorHeath Stewart27-Apr-04 5:30 
GeneralRe: How to lunch htm through C# code Pin
Alex Getman27-Apr-04 6:25
Alex Getman27-Apr-04 6:25 
GeneralRe: How to lunch htm through C# code Pin
Alex Getman27-Apr-04 6:38
Alex Getman27-Apr-04 6:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.