473,385 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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

Aug 30 '06 #1
0 1209

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: JRoe | last post by:
Hello, I am beside myself with this problem. I need to access unmanged C++ code in a C# environment. I have created a managed C++ wrapper that wraps the unmanaged class. When I call the...
1
by: Bob Whiton | last post by:
I have an unmanaged class which has a member variable: gcroot<DataTable*> myDataTable; I would like to sink the RowDeleting event in my UNmanaged class. However, I can't declare an event...
4
by: Rachel Suddeth | last post by:
What is the difference between a managed/unmanaged resource, and how do you tell which is which? I'm trying to understand how to write some Dispose() methods, and we are supposed to put code that...
5
by: Paul Brun | last post by:
Hi guys, I would like to find out if : 1) Is the above possible? I have tried to wrap a C library that our company produces in a .Net class library and am receiving the following error: ...
0
by: Arnaud Debaene | last post by:
Hello all. I've got a bunch of existing, non managed, C++ DLLs that export types with, among other things, public events implemented using the boost::signals library. Now, I need to have...
1
by: Sparhawk | last post by:
Hi, my company is going to migrate a large VC++ application to .NET to make use of Windows Forms (the old class library is not updated any more). We are not planning to migrate the rest of the...
2
by: bonk | last post by:
Hello, I have a managed type that defines an Event as one of its public members. Is it possible for an unmanaged c++ class to register to that event ? How can an unmanaged classmethod be called...
0
by: Mayur | last post by:
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#...
2
by: Mayur | last post by:
Hello all, Can any one have the source of How to add event handler in unmanaged MFC application for event source which is in Managed(c# class library). Here is the Event Source code :...
1
by: Grant Schenck | last post by:
Hello, I built a client application using C# .NET 2.0. It runs fine at a number of customer sites. One customer is reporting several users getting problems. At start up it crashes with a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.