473,326 Members | 2,110 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,326 software developers and data experts.

Implementing C# Interfaces into a managed C++ Class?

my C# code interface:

namespace IShared;
{
public interface IChannelEntity
{
void SendMsg(string p_msg);
void Exit();
}
public interface IChannelEntityCallBack
{
[OneWay]
void RcvMsg(string p_msg);
}
}

I am trying to figure out how to implement my Interfaces into a c++ managed class. Here is what I got in my cpp file:

namespace EMRBridge
{
//gc managed c++ class
EMRBridge::EMRBridge( )
{

}
void EMRBridge::SendMsg(IChannelEntity *EMR_IChannelEntity, String *p_msg)
{
try {
EMR_IChannelEntity->SendMsg(p_msg);
}
catch (Exception* ex) {
Console::WriteLine( ex->ToString( ) );
}
}

void EMRBridge::ReceiveMsg(IChannelEntityCallBack *rcv, String *p_msg)
{
try {
rcv->RcvMsg(p_msg);
}
catch(Exception* ex){
Console::WriteLine( ex->ToString( ) );
}
}
}

I will have another question after this. Basically this interface I have is for a message router. The IChannelEntity and IChannelCallBack are Interfaces. Did I code the functions right to accept an object and a string correctly? I have never written a managed c++ file that implements c# code interfaces.

my header:

// EMRBridge.h

#pragma once
#using <mscorlib.dll>
#using <System.dll>
#using <System.Runtime.Remoting.dll>

using namespace System;
using namespace System;
using namespace System::Data;
using namespace System::Xml;
using namespace System::Threading;
using namespace System::Runtime::Remoting::Services;
using namespace MB;
using namespace IShared;

namespace EMRBridge
{
__gc class EMRBridge
{
public:
EMRBridge();

IShared::IChannelEntity *EMR_IChannelEntity;

//Send Messages
public:
void SendMsg(IChannelEntity *EMR_IChannelEntity, String *p_msg);

//Receive Messages
public:
void ReceiveMsg(IChannelEntityCallBack *rcv, String *p_msg);

};
}

_____________________
Message posted via http://www.dotnetmonster.com
Nov 17 '05 #1
0 986

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

Similar topics

7
by: mdc | last post by:
Hi, Is there any way to implement an interface as a static method in C#? If not, is this a bug? Micheal.
2
by: Martin Zenkel | last post by:
Dear VS Team, using the Beta 2 of VS 2005 I've encontered the following problem. Let's assume threre are three Dll's, one unmanaged and two managed. In the unmanaged we put a simple unmanged...
4
by: phl | last post by:
hi, My question is: 1. To avoid possible memory leaks, when you use this pattern, after you have dealth with the unmanaged resources and before you take your object off the finalize queue,...
2
by: DaTurk | last post by:
I have three interfaces, lets call them General, Client, Server. public interface General { public Value{get;} } public interface Client : General {}
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.