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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt Sipes via DotNetMonster.com

    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 IChannelEntityC allBack
    {
    [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::EMRB ridge( )
    {

    }
    void EMRBridge::Send Msg(IChannelEnt ity *EMR_IChannelEn tity, String *p_msg)
    {
    try {
    EMR_IChannelEnt ity->SendMsg(p_msg) ;
    }
    catch (Exception* ex) {
    Console::WriteL ine( ex->ToString( ) );
    }
    }

    void EMRBridge::Rece iveMsg(IChannel EntityCallBack *rcv, String *p_msg)
    {
    try {
    rcv->RcvMsg(p_msg );
    }
    catch(Exception * ex){
    Console::WriteL ine( ex->ToString( ) );
    }
    }
    }

    I will have another question after this. Basically this interface I have is for a message router. The IChannelEntity and IChannelCallBac k 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::Threadi ng;
    using namespace System::Runtime ::Remoting::Ser vices;
    using namespace MB;
    using namespace IShared;

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

    IShared::IChann elEntity *EMR_IChannelEn tity;



    //Send Messages
    public:
    void SendMsg(IChanne lEntity *EMR_IChannelEn tity, String *p_msg);

    //Receive Messages
    public:
    void ReceiveMsg(ICha nnelEntityCallB ack *rcv, String *p_msg);

    };
    }

    _______________ ______
    Message posted via http://www.dotnetmonster.com
Working...