Referencing assemblies after loading

Codeless

Well-known member
Joined
Jan 24, 2003
Messages
59
Location
Great NW
I have a program that loads an assembly into an AppDomain. The part I dont get (yet) is how do I reference any of the classes inside the assembly that was loaded at run-time? Inside this dll is a form that I want to open. Anytime I try to call it from my program I cant because it is not declared. Should I declare it somewhere? Whats the best way to handle this?
 
If you know the name of the object you can create an instance of it using Reflection:
Code:
Get the DLL
Dim dll As Reflection.Assembly = Reflection.Assembly.LoadFrom("dll path")
Create an instance of the specified object
Dim yourobject As Object = dll.CreateInstance("type name")
 
In the test.dll I have:

namespace: Test
Class testInterface

I want to load the .dll and access the testInterface class:

Dim dll As Reflection.Assembly = Reflection.Assembly.LoadFrom("c:\Test.dll")
Dim yourobject As Object = dll.CreateInstance("testInterface")
 
oh i think i figured something out just now. I have to use "test.testinterface" instead of just "testinterface" where the createinstance command runs:

Dim yourobject As Object = dll.CreateInstance("test.testInterface")
 
ok how do i now setup a function to recieve events from this class?

I have a sub called "receiveCall", and inside the dll I have:

PUBLIC EVENT callReceive (byval pString as string)

in my form I have the following:
AddHandler myobject.callreceive, AddressOf ReceiveCall

which seems to error out please advise.
 
Back
Top