none
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 http://www.x-io.co.uk/node/9 . 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 http://www.x-io.co.uk/node/2 , 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  http://msdn.microsoft.com/en-us/library/ak9w5846(v=VS.90).aspx  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
    {
      [Guid("40EEEB8C-E30C-4ea8-9220-6456CF868F97")]
      [ComVisible(true)]
      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;
    
        #endregion
      }
    
      [Guid("7D66A372-69CC-4482-8EDE-98A1CBD6BCC4")]
      [ComVisible(true)]
    
      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); }
        #endregion
      }
    }
    
    

    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 


    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