Loading referenced DLL's

P

Patrick Ravi-Pinto

Dear colleagues,
i'm new in the .net programming and hope you can help me.

I have two classes: Employee and Address
The Employee class has a reference to the Address and imports them on the
top.

I can test it locally, and it works but now I wants to load the Employee-DLL
with this code:

Public Function executeDllMethod(ByVal DllPath As String, ByVal ClassName As
String, ByVal DLLMethod As String) As Object
Dim myAssembly As Assembly
myAssembly = Assembly.LoadFrom(DllPath)

Dim myMethod As MethodInfo
Dim myType As Type
myType = myAssembly.GetType(ClassName)
'MsgBox(DLLMethod.ToString)
myMethod = myType.GetMethod(DLLMethod)

Dim o As New Object
o = Activator.CreateInstance(myType)
Dim result As Object
result = myMethod.Invoke(o, Nothing)
Return result


But it does not work. I receive only an error, that the Address-DLL cannot
be loaded (File not found)
When I register the Address-DLL in the GAC it works.

Do you know a solution without using the GAC or where's/what's the problem?

Thanks
Patrick
 
V

Vladimir Matveev

Question, does DllPath contains full path to dll location?
FileNotFoundException makes me think that there are no assembly on
<DllPath>.

<APPFOLDER> - application folder
<ASSEMBLY_NAME> - assembly name
<CULTURE> - assembly culture info

You should place your assembly in <APPFOLDER> or
<APPFOLDER>\<ASSEMBLY_NAME> directory

if assembly has culture info then loader shall try to find it in the
following locations
<APPFOLDER>\<CULTURE>
<APPFOLDER>\<ASSEMBLY_NAME>\<CULTURE>
 
A

Antonio Paglia

Try using the Assembly FullName

Es:

Dim testAssembly As AssemblyName =
System.Reflection.AssemblyName.GetAssemblyName(AssemblyName & ".dll")

asm = [Assembly].Load(testAssembly.FullName)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top