Codeless Posted January 29, 2004 Posted January 29, 2004 I have a program that loads an assembly into an AppDomain. The part I don't 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 can't because it is not declared. Should I declare it somewhere? Whats the best way to handle this? Quote Codeless ...it just goes on and on.
*Experts* mutant Posted January 29, 2004 *Experts* Posted January 29, 2004 If you know the name of the object you can create an instance of it using Reflection: '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") Quote
Drstein99 Posted January 30, 2004 Posted January 30, 2004 I do this exact process, and under "yourobject" which is where createinstance is run, it always waches to "NOTHING". Any ideas? Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
Administrators PlausiblyDamp Posted January 30, 2004 Administrators Posted January 30, 2004 Could you show us some code and give some details about class names / dll names and locations? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Drstein99 Posted January 30, 2004 Posted January 30, 2004 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") Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
Drstein99 Posted January 30, 2004 Posted January 30, 2004 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") Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
Drstein99 Posted January 31, 2004 Posted January 31, 2004 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. Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.