Visual Basic Development Bookmark and Share   
 Home > Visual Basic Interop and Upgrade > handle a .net Com Class event in vb6 - not works
 

handle a .net Com Class event in vb6 - not works

i havethe ComClassSearchCustomersclass and interface IComClassSearchCustomersat .net which used to create a tlb file. Theclass raise an eventinside new. After that i have a vb6form Form1 which catch the event , but it never see the event. Any ideas?
Option Strict On
Option Explicit On
Imports System.Runtime.InteropServices

<Guid("BB86EB1C-6444-424f-B83B-A667561E06C3"), _
ComSourceInterfaces(GetType(IComClassSearchCustomers))> _
Public Class ComClassSearchCustomers

    Public Delegate Sub printReportEventHandler(ByVal codes As String)
    Public Event printReport As printReportEventHandler

       Public Sub New()
         MyBase.New()
         RaiseEvent printReport
    End Sub
End Class


Imports System.Runtime.InteropServices

<Guid("D8F7EC74-0EFC-4e43-9B59-4CF741DF616D"), _
InterfaceType(ComInterfaceType.InterfaceIsIDispatch)> _
Public Interface IComClassSearchCustomers
    <DispId(1)> _
            Sub printReport(ByVal codes As String)
End Interface
Public WithEvents Instance As Search.ComClassSearchCustomers

 Private Sub Form_Load()
 Set Instance = New Search.ComClassSearchCustomers
End Sub

Private Sub Instance_printReport(ByVal codes As String)
MsgBox ("raise")
End Sub
blachogi  Friday, November 13, 2009 9:17 AM
Also see this code sample for exposing .NET component as the COM object. There is one VBDllCOMServer project. It shows how to expose the events for COM client application. It should satisfy your requirement.
http://cfx.codeplex.com/
Best regards,
Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Riquel_Dong  Thursday, November 19, 2009 9:56 AM
Please have a look at this sample for your reference.
http://social.msdn.microsoft.com/forums/en/vbinterop/thread/6d4a8dc9-8267-4c21-a79e-cdcd2b7abc1f
Best regards,
Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Riquel_Dong  Tuesday, November 17, 2009 10:01 AM
Also see this code sample for exposing .NET component as the COM object. There is one VBDllCOMServer project. It shows how to expose the events for COM client application. It should satisfy your requirement.
http://cfx.codeplex.com/
Best regards,
Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Riquel_Dong  Thursday, November 19, 2009 9:56 AM

You can use google to search for other answers

Custom Search

More Threads

• VB6 project to VB.NET/VB2005 conversion problem
• To Convert Interop Controls from 1.0 to 2.0
• Interop Forms Redistributable Package 2.0a Prerequisitie Does Not Install
• VB6 to VS 2008 Upgrade question
• CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(My.Settings.homepage.ToString)
• VB6 interop UserControl not input Chinese character?
• Replace COM xyz.dll with .NET CCW xyz.tlb
• Using an Installed User Interopcontrol
• XMLFile.Code
• Could not resolve dependent COM reference Interop.VBRUN