Results 1 to 7 of 7

Thread: Event problem

  1. #1

    Thread Starter
    Lively Member matt3011's Avatar
    Join Date
    May 2002
    Location
    France
    Posts
    82

    Event problem

    I'm loading plugin dynamically through the reflection assembly.
    I have implemented an interface which must be implemented in each plugin.
    I want to be able to access the events raised by those plugins and implemented in the interface. I cant use the addHandler method because i write AddHandler myvar.myevent ,AddressOf myMethod. It says myvar has not an event called "myevent". myvar is declared as object.
    How can I do, I can't add reference to each plugin class(or it wont be useful to implement a plugin model as i have to reference them in my project) ?

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Does your interface have definitions of events? If these events are defined in the interface, you can receive them by casting the object to an object of your iterface, then you can wire up the event.

    That is my theory anyway...lol.

  3. #3

    Thread Starter
    Lively Member matt3011's Avatar
    Join Date
    May 2002
    Location
    France
    Posts
    82
    Yes events are defined in the interface.
    I tried to cast myvar to an object of your iterface and i have a cast error but, the more surprising is that I tried directly with a plugin I reference and i still get the cast error. For example :

    dim myvar as myclass

    sub loadvar()
    ...
    asm=Reflection.Assembly.LoadFrom(mypath)
    Dim tys() As Type = asm.GetTypes
    Dim t As Type
    For Each t In tys
    If Not t.GetInterface("Player") Is Nothing Then
    Myvar = asm.CreateInstance(t.FullName)
    End If
    Next
    end sub

    Here I have an error and i'm sure there is only one class which implements Player.
    It is a bit confusing, i dont know what to think about that

  4. #4

    Thread Starter
    Lively Member matt3011's Avatar
    Join Date
    May 2002
    Location
    France
    Posts
    82
    AnyBody ?

  5. #5
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Use C#, the event model is much simpler.

  6. #6

    Thread Starter
    Lively Member matt3011's Avatar
    Join Date
    May 2002
    Location
    France
    Posts
    82
    Since I don't know C#and i know everything done in any of the .net language can be done in another one, i'd prefer to stay in pure VB.Net .

    I have another way to do this events to fire with a particular way which is to specify the form I'm using when creating the new Object and though I can access methods of this form But I'd prefer to do it with evnts and i know it can be done

  7. #7
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    But C# is much cooler

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