Announcement

Collapse
No announcement yet.

Events do not fire when running from VB.NET

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Thomas Tierney
    replied
    unless I am doing something wrong Events will not work in VB.NET

    using this, it crashes on oUser.CreateObject("IUSER") with An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Interop.USERMANAGER.dll

    Additional information: Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

    Code:
    Public Class Form1
        Private WithEvents oUser As USERMANAGER.IUSER
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            oUser = CreateObject("IUSER")
            oUser.Save()
            oUser = Nothing
        End Sub
    
        Public Sub New()
            ' This call is required by the Windows Form Designer.
            InitializeComponent()
            ' Add any initialization after the InitializeComponent() call.
        End Sub
    
        Private Sub oUser_DONE() Handles oUser.DONE
            MsgBox("DONE")
        End Sub
    End Class

    Leave a comment:


  • Thomas Tierney
    replied
    Jose,

    I tried with IUNKNOWN, IDISPATCH and DUAL and it revealed the same results

    Leave a comment:


  • José Roca
    replied
    CLASS iEvent GUID$("{2A14E72D-37A7-4279-8CEA-6A46227C524B}") AS COM

    INTERFACE STATUS GUID$("{40246A94-7411-491B-B2E3-C724AC07199C}") AS EVENT
    INHERIT IUNKNOWN
    METHOD Done Alias "Done"
    MSGBOX "DONE"
    END METHOD
    END INTERFACE
    END CLASS
    VB uses dispatch events. You should try changing Inherit IUnknown to Inherit IDispatch.

    Leave a comment:


  • Peter Redei
    replied
    I actually tried to use PB COM class from C# by referencing it. VS'2005 refused it and I gave it up. What you did in VB.NET is the same that you would have done in VB6 and this way events cannot be handled.

    As far as I am concerned even if there is a way of using PB COM objects from VB but not on the traditional way that is useless. I think we all want to create development tools, so users have to be able to use them as any other COM objects.

    Peter Redei

    Leave a comment:


  • Thomas Tierney
    started a topic Events do not fire when running from VB.NET

    Events do not fire when running from VB.NET

    It took me awhile to get this all straightened out but I was able to use a pb dll via interop in VS 2005. The program is below

    #COMPILE DLL
    #DIM ALL

    #COM NAME "EVENTMANAGER", 1.0
    #COM TLIB ON
    #COM DOC "FOO MAN GROUPS"

    CLASS iEvent GUID$("{2A14E72D-37A7-4279-8CEA-6A46227C524B}") AS COM

    INTERFACE STATUS GUID$("{40246A94-7411-491B-B2E3-C724AC07199C}") AS EVENT
    INHERIT IUNKNOWN
    METHOD Done Alias "Done"
    MSGBOX "DONE"
    END METHOD
    END INTERFACE
    END CLASS

    CLASS IEVENTCALLER GUID$("{746E01B8-5878-4582-88CF-82DAC9EC5B5B}") AS COM
    INTERFACE USER GUID$("{FEFCE87D-F193-4184-9781-951CAD5E12F2}")
    INHERIT DUAL
    METHOD SAVE ALIAS "Save"()
    RAISEEVENT STATUS.DONE()
    END METHOD
    END INTERFACE
    EVENT SOURCE STATUS
    END CLASS



    In VB.NET I create a windows app and add this to the form


    WithEvents oUser As EVENTMANAGER.USER



    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    oUser = CreateObject("USER")
    oUser.Save()
    oUser = Nothing

    End Sub

    Private Sub oUser_DONE() Handles oUser.DONE
    MsgBox("DONE")

    End Sub


    The event never fires?

    Anyone get events to work with .Net Yet?
Working...
X