PC Review


Reply
Thread Tools Rate Thread

creating event handler in unmanaged c++ code for event in managed code

 
 
Mayur
Guest
Posts: n/a
 
      30th Aug 2006
Hello all,
Im trying to call my .net c# library functions from my unmanaged
vc++(dialog based MFC)
application .
From that application i want add the event handler for the event generated
in c# dll which generates the event calles as Message Income
my c# dll code is like this

namespace ircConnect

{

public class IrcConnection

{

public delegate void MessageEventHandler(object sender,MessageEventArgs e);

public event MessageEventHandler MessageIncome;

}

Here is my vc++ code.


#using <mscorlib.dll>

#using "ircConnect.dll" //This is the c# dll reference


__gc class GlobalObjects

{

#pragma push_macro("new")

#undef new

public: static ircConnect::IrcConnection *iIRC =new
ircConnect::IrcConnection();


void OnMessageIncome( Object* sender,
ircConnect::IrcConnection::MessageEventArgs* e )

{

MessageBox(NULL,e->Message->Sender->ToString(),"",1);


}

public:
__event ircConnect::IrcConnection::MessageEventHandler*
MessageIncome;

#pragma pop_macro("new")
};

void CMyMFCDlg::OnBnClickedOk() //On Button click
{
#pragma push_macro("new")
#undef new
GlobalObjects* m_proxyChat;
m_proxyChat = new GlobalObjects();
GlobalObjects *MyX = new GlobalObjects();
m_proxyChat->MessageIncome += new
ircConnect::IrcConnection::MessageEventHandler(MyX,GlobalObjects::OnMessageIncome);
//This is the event handler im trying to add

m_proxyChat->iIRC->Connect("testing");
m_proxyChat->iIRC->joinchannel("abhishek","abhishek","#guildae");
#pragma pop_macro("new")
}



But actually this event is not generated properly and function
OnMessageIncome will not be getting called;

So can u give me exact snippet for How to create event handler in unmanaged
vc++ code for event generated in Managed(c#) dll



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
creating event handler in unmanaged c++ code for event in managed code Mayur Microsoft VC .NET 0 30th Aug 2006 01:22 PM
Managed event source, unmanaged event sink =?Utf-8?B?TWFyaW8gR2lhY29taW5v?= Microsoft Dot NET 0 15th Jul 2005 11:51 PM
Run event handler code from outside of event =?Utf-8?B?U2lvYmhhbg==?= Microsoft VB .NET 3 17th May 2004 09:21 AM
Best practice needed to marshal STL data from managed code to unmanaged code & vice versa =?Utf-8?B?UFNQX1VOSl9NU19OZXdzZ3JvdXBfUmVxdWVzdEBw Microsoft VC .NET 0 11th Mar 2004 12:21 PM
Best practice needed to marshal STL data from managed code to unmanaged code & vice versa =?Utf-8?B?Sm9oYW5uZXMgVW5mcmllZA==?= Microsoft VC .NET 0 27th Feb 2004 09:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:44 PM.