Results 1 to 3 of 3

Thread: How AddHandler from C# DLL to VB Proj

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2016
    Posts
    4

    How AddHandler from C# DLL to VB Proj

    Someone know how addhandlers from C# DLL to VB App. When I try to use AddHandler into my VB project, the Visual Studio returns:

    Error BC30676 'DebugMessageEvent' is not an event of 'Debugger'...

    Name:  Captura de pantalla 2016-11-27 14.31.52.jpg
Views: 768
Size:  10.1 KB

    If I go to the 'DebugMessageEvent' definition from VB Proj (Auto-Converted from the DLL called DLLNAMESPACE), I get the follow code:

    Code:
    Public Class Debugger
        Public DebugMessageEvent As EventHandler(Of DebugMessageArgs)
    
        Public Shared ReadOnly Property Instance As Debugger
    
        Public Class DebugMessageArgs
            Inherits EventArgs
    
            Public Sub New()
    
            Public Property Message As Object
        End Class
    End Class
    The VB Project (Doesn't Work)

    Code:
    AddHandler Instance.DebugMessageEvent, AddressOf console_DebugMessageEvent
    Another C# project (Works)

    Code:
    Debugger.Instance.DebugMessageEvent += console_DebugMessageEvent;
    Name:  Captura de pantalla 2016-11-27 14.35.50.jpg
Views: 712
Size:  7.8 KB

    The DLL C# Code

    Code:
    public sealed class Debugger
    {
        private static readonly Lazy<Debugger> instance = new Lazy<Debugger>(() => new Debugger());
    
        private Debugger()
        {
    
        }
    
        public static Debugger Instance
        {
            get { return instance.Value; }
        }
    
        public EventHandler<DebugMessageArgs> DebugMessageEvent;
    
        public class DebugMessageArgs : EventArgs
        {
            public object Message { get; set; }
        }
    
        private void RaiseDebugMessageEvent(object message)
        {
            DebugMessageEvent?.Invoke(this, new DebugMessageArgs
            {
                Message = message
            });
        }
    
        internal void DebugMessage(object data)
        {
            RaiseDebugMessageEvent(data);
        }
    }
    All the rest of DLL functions works as expected.
    Last edited by eliaspizarro; Nov 27th, 2016 at 03:43 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width