unmanaged calls from managed code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • James L. Brown

    #1

    unmanaged calls from managed code

    Hello

    I'm currently working on a project, that contains one .net (VB) executable and a C++ (MFC) DLL. Now, what I want to do is to call the functions in the dll out of my managed code
    //managed cod
    Public Class Win32Call
    <StructLayout(L ayoutKind.Seque ntial)>
    Class MYSTRUC
    Public counter1 As Int6
    Public counter2 As Int6
    End Clas

    Declare Function TestMarshalling Lib "test.dll" (ByVal stats As MYSTRUCT) As Boolea
    End Clas

    //[...
    dim s as New Win32Calls.MYST RUC
    //filling s..
    Win32Calls.Test Marshalling(s) '!!!

    At this point, the debugger throws a System.NullRefe renceException - can anyone tell me why?

    Thanks a lo
    Jame

    P.S.: This is the unmanaged code
    typedef struct _MYSTRUCT
    __int64 counter1
    __int64 counter2
    }MYSTRUCT

    BOOL TestMarshalling (MYSTRUCT stats

    AfxMessageBox(" Inside the DLL")
    [...



Working...