Advertisement

05.27.2008 at 10:48AM PDT, ID: 23435699
[x]
Attachment Details

in VB.NET how do i get a dll instance to access a method from the main form class?

Asked by RichardRiga in Microsoft Visual Basic.Net, .NET, .NET Framework 2.0

Hello!

I have two projects.  One is a standard vb.net windows application and the second is a DLL with one function that returns a simple string.
Public Class DLLClass
     public function TestDLL () as string
        return "Dude, I'm here"
     end function
End Class

In my windows app, i late bind this DLL and invoke its method:
        Dim assAssembly As Reflection.Assembly = Nothing
        Dim typeClassType As Type = Nothing
        Dim strReturn As String = ""

         assAssembly = Reflection.Assembly.LoadFrom(strApplicationPath & strDLLName)
         typeClassType = assAssembly.GetType("DLLClass.DLLClass")
         objClassInstance = Activator.CreateInstance(typeClassType)

         MessageBox.Show(objClassInstance.TestDLL)

This works fine.  But what if I want the DLL to access a method from the main application?  Can someone please show me an example of how that is done?  Again, keep in mind that the dll is late bound.
ThanksStart Free Trial
[+][-]05.27.2008 at 11:17AM PDT, ID: 21654256

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 11:51AM PDT, ID: 21654503

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual Basic.Net, .NET, .NET Framework 2.0
Sign Up Now!
Solution Provided By: DarrenD
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628