Click here to Skip to main content
15,913,198 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: KeyDown problem Pin
AnsGe9-Oct-04 0:43
AnsGe9-Oct-04 0:43 
GeneralRe: KeyDown problem Pin
yuvald9-Oct-04 1:59
yuvald9-Oct-04 1:59 
Generalambiguous error Pin
ISUstudent7-Oct-04 14:19
ISUstudent7-Oct-04 14:19 
GeneralStrings Pin
gremlin067-Oct-04 8:04
gremlin067-Oct-04 8:04 
GeneralRe: Strings Pin
George L. Jackson8-Oct-04 2:39
George L. Jackson8-Oct-04 2:39 
GeneralRe: Strings Pin
AnsGe8-Oct-04 21:18
AnsGe8-Oct-04 21:18 
GeneralRe: Strings Pin
Gammill11-Oct-04 8:49
Gammill11-Oct-04 8:49 
GeneralDelegate not working... Pin
David Moody7-Oct-04 4:07
David Moody7-Oct-04 4:07 
Hey guys, I'm trying to get a callback function to work from my unmanaged C++ dll. Everytime I run my program I get System.NullReferenceException saying "Object reference not set to an instance of an object." in mscorlib. This error is thrown when the runtime tries to execute the callback function in my unmanaged C++ DLL.

What I'm trying to do is real simple and straightforward:

namespace ProtocolDll
{
__delegate void MY_CALLBACK();

[DllImport("test.dll")]
extern "C" void UnmanagedFunc(MY_CALLBACK __gc* myCallback);

public __gc class Wrapper
{
public:
void myCallback()
{
MY_CALLBACK* cb = new MY_CALLBACK(this,&Wrapper::CallMePlease);

UnmanagedFunc(cb); // Call the unmanaged dll function
}

void CallMePlease()
{
Int32 i=0;

i=i+1; // I put a breakpoint here but it never makes it
};
}

************************************
Here is my unmanaged C++ dll code:

typedef void (*MY_CALLBACK)();

EXPORT void UnmanagedFunc(MY_CALLBACK* pfnCallback);

void UnmanagedFunc(MY_CALLBACK* pfnCallback)
{
(*pfnCallback)();
}

Any idea what I am doing wrong? Thanks for any help... this is my last issue with this unmanaged dllimport stuff... this code is a bear to write.

david


Questionanyone know how to connect...? Pin
porac696-Oct-04 14:25
porac696-Oct-04 14:25 
GeneralVery frustrating dllimport code.. Pin
David Moody6-Oct-04 5:42
David Moody6-Oct-04 5:42 
GeneralRe: Very frustrating dllimport code.. Pin
ursus zeta6-Oct-04 9:50
ursus zeta6-Oct-04 9:50 
GeneralRe: Very frustrating dllimport code.. Pin
David Moody7-Oct-04 4:10
David Moody7-Oct-04 4:10 
Generalplease please please help me Pin
youngashish5-Oct-04 22:39
youngashish5-Oct-04 22:39 
GeneralRe: please please please help me Pin
Phil J Pearson5-Oct-04 22:54
Phil J Pearson5-Oct-04 22:54 
GeneralRe: please please please help me Pin
Anonymous5-Oct-04 22:59
Anonymous5-Oct-04 22:59 
Generalproblem Pin
ISUstudent5-Oct-04 14:55
ISUstudent5-Oct-04 14:55 
GeneralRe: problem Pin
Anonymous5-Oct-04 15:27
Anonymous5-Oct-04 15:27 
GeneralRe: problem Pin
Christian Graus5-Oct-04 15:38
protectorChristian Graus5-Oct-04 15:38 
GeneralRe: problem Pin
toxcct5-Oct-04 21:13
toxcct5-Oct-04 21:13 
GeneralRe: problem Pin
Anonymous6-Oct-04 4:11
Anonymous6-Oct-04 4:11 
GeneralRe: problem Pin
R.Pincince13-Oct-04 5:10
R.Pincince13-Oct-04 5:10 
GeneralProject settings Pin
Jose Vicente5-Oct-04 5:41
Jose Vicente5-Oct-04 5:41 
GeneralA CHALLENGE Pin
tobermori4-Oct-04 15:36
tobermori4-Oct-04 15:36 
GeneralDirectX 9 SDK (Summer 2004) Pin
pauldomag3-Oct-04 6:23
pauldomag3-Oct-04 6:23 
GeneralRe: DirectX 9 SDK (Summer 2004) Pin
Christian Graus5-Oct-04 15:41
protectorChristian Graus5-Oct-04 15:41 

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.