|
-
May 28th, 2003, 02:15 PM
#1
Thread Starter
Lively Member
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) ?
-
May 28th, 2003, 02:24 PM
#2
PowerPoster
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.
-
May 28th, 2003, 02:49 PM
#3
Thread Starter
Lively Member
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
-
May 28th, 2003, 05:41 PM
#4
Thread Starter
Lively Member
-
May 28th, 2003, 05:48 PM
#5
Frenzied Member
Use C#, the event model is much simpler.
-
May 28th, 2003, 05:59 PM
#6
Thread Starter
Lively Member
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
-
May 28th, 2003, 09:09 PM
#7
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|