Click here to Skip to main content
16,006,375 members
Home / Discussions / C#
   

C#

 
GeneralRe: Import unmanaged C++ dll into C# project Pin
Mark Salsbery13-Oct-08 8:04
Mark Salsbery13-Oct-08 8:04 
QuestionRe: Import unmanaged C++ dll into C# project Pin
Mark Salsbery13-Oct-08 8:22
Mark Salsbery13-Oct-08 8:22 
AnswerRe: Import unmanaged C++ dll into C# project Pin
jamesmurphy7813-Oct-08 8:43
jamesmurphy7813-Oct-08 8:43 
GeneralRe: Import unmanaged C++ dll into C# project Pin
Mark Salsbery13-Oct-08 9:33
Mark Salsbery13-Oct-08 9:33 
GeneralRe: Import unmanaged C++ dll into C# project Pin
jamesmurphy7813-Oct-08 10:03
jamesmurphy7813-Oct-08 10:03 
GeneralRe: Import unmanaged C++ dll into C# project Pin
Mark Salsbery13-Oct-08 10:57
Mark Salsbery13-Oct-08 10:57 
GeneralRe: Import unmanaged C++ dll into C# project Pin
jamesmurphy7813-Oct-08 11:24
jamesmurphy7813-Oct-08 11:24 
GeneralRe: Import unmanaged C++ dll into C# project Pin
Mark Salsbery13-Oct-08 11:33
Mark Salsbery13-Oct-08 11:33 
jamesmurphy78 wrote:
I'm getting an AccessViolationException


Yeah I was just going to send you what should be the final fix.

Delegates should be called using __stdcall...

On the C++ side:
DllImpExp int PcDllInit(const char PcDllPwd[64], int AutoDeleteFlag, 
                        int LogFlag,
                        void (<code>__stdcall</code> PcMsgCb)(PC_MSG_TYPE PcMsgType, 
                        const char MsgTgt[MAX_PCDLL_STRING_LEN],
                        int Verbosity, 
                        const char Msg[512]));

I tested with Strings, not StringBuilders and it seemed to work well.
You can get rid of the "SizeConst =" on the C# side marshaling, since the size can't
be enforced anyway (only array pointers are being passed). Having them there,
however, does document the max string sizes I guess.

Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

GeneralRe: Import unmanaged C++ dll into C# project Pin
jamesmurphy7813-Oct-08 11:53
jamesmurphy7813-Oct-08 11:53 
GeneralRe: Import unmanaged C++ dll into C# project Pin
Mark Salsbery13-Oct-08 12:04
Mark Salsbery13-Oct-08 12:04 
QuestionGetHashCode implementation Pin
DaveyM6910-Oct-08 11:45
professionalDaveyM6910-Oct-08 11:45 
AnswerRe: GetHashCode implementation Pin
Guffa10-Oct-08 12:26
Guffa10-Oct-08 12:26 
GeneralRe: GetHashCode implementation Pin
DaveyM6910-Oct-08 12:54
professionalDaveyM6910-Oct-08 12:54 
GeneralRe: GetHashCode implementation Pin
DaveyM6910-Oct-08 13:05
professionalDaveyM6910-Oct-08 13:05 
GeneralRe: GetHashCode implementation Pin
Guffa10-Oct-08 14:09
Guffa10-Oct-08 14:09 
QuestionFinding in datagridview Pin
ArielR10-Oct-08 11:43
ArielR10-Oct-08 11:43 
AnswerRe: Finding in datagridview Pin
Pedram Behroozi10-Oct-08 12:21
Pedram Behroozi10-Oct-08 12:21 
AnswerRe: Finding in datagridview Pin
nelsonpaixao10-Oct-08 12:38
nelsonpaixao10-Oct-08 12:38 
AnswerRe: Finding in datagridview Pin
Wendelius10-Oct-08 22:01
mentorWendelius10-Oct-08 22:01 
Questionform_load and performclick() Pin
Saamir10-Oct-08 10:46
Saamir10-Oct-08 10:46 
AnswerRe: form_load and performclick() Pin
vineas10-Oct-08 11:03
vineas10-Oct-08 11:03 
GeneralRe: form_load and performclick() Pin
Saamir13-Oct-08 4:43
Saamir13-Oct-08 4:43 
AnswerRe: form_load and performclick() Pin
Pedram Behroozi10-Oct-08 11:04
Pedram Behroozi10-Oct-08 11:04 
GeneralRe: form_load and performclick() Pin
Saamir10-Oct-08 11:06
Saamir10-Oct-08 11:06 
GeneralRe: form_load and performclick() Pin
Pedram Behroozi10-Oct-08 11:12
Pedram Behroozi10-Oct-08 11:12 

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.