interface events in C# Class library project to expose it to COM RRS feed

  • Question

  • Hi all,

    I have an API source which "Open source xIMU API 11.0" here . I'm trying to make that Class Library project for COM interface( Interop)

    to use the DLL in VC++. I'm new to C#, I bought product of , they have C#, but I'm using VC++ . That is the reason why I'm in C#.

    I followed several articles regarding .NET COM Interop . There are events in the source code "xIMUserial.cs"(Please download & open the class file)

    Now, I saw the MSDN  for interface events

    would you please tell me how can i make the events inside xIMUserial.cs class to expose them in COM interface.

    I tried the following( i think it is wrong, only doubtful part of the namespace is written below)

    namespace x_IMU_API
      public interface IxIMUserial
         #region Packet reception methods
          delegate void onxIMUdataReceived(object sender, 
                                     xIMUdata e);
          event onxIMUdataReceived xIMUdataReceived;
          delegate void onErrorDataReceived(object sender, 
                                    ErrorData e);
          event onErrorDataReceived ErrorDataReceived;
      public class xIMUserial : IxIMUserial
         #region Packet reception methods
         public delegate void onxIMUdataReceived(object sender, 
           xIMUdata e);
        public event onxIMUdataReceived xIMUdataReceived;
        protected virtual void OnxIMUdataReceived(xIMUdata e) { if 
           (xIMUdataReceived != null) xIMUdataReceived(this, e); }
        public delegate void onErrorDataReceived(object sender, 
           ErrorData e);
        public event onErrorDataReceived ErrorDataReceived;
        protected virtual void OnErrorDataReceived(ErrorData e) { if
          (ErrorDataReceived != null) ErrorDataReceived(this, e); }

    Thank you all

    • Moved by Rob Pan Monday, August 1, 2011 5:57 AM for better support (From:Visual C++ General)
    Thursday, July 28, 2011 8:14 AM

All replies

  • Hi,


    According to you description, it seems that your thread is not  about Visual C++ development. So I will move it to the correct forum for better support. Thanks for your understanding.


    Best Regards,


    Rob Pan [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, August 1, 2011 5:54 AM