Loading 2 dll using System.Reflection.Assembly.LoadFrom

tohnsm

New member
Joined
Sep 20, 2007
Messages
4
Programming Experience
1-3
Hi.

I am working on a program that requires me to load 2 dll at runtime.

My code is as shown below:

VB.NET:
Dim i as object
Dim j as object

Dim a As System.Reflection.Assembly = System.Reflection.Assembly.LoadFrom("C:\a.dll")

j = a.CreateInstance("ClassLibrary1.Class2")

Dim b As System.Reflection.Assembly = System.Reflection.Assembly.LoadFrom("C:\b.dll")

i = b.CreateInstance("ClassLibrary1.Class1")

Dim str1 As String = j.ret()

Dim aaaa As Boolean = i.his()

But an exception hsa occurred when i.his() is called. Apparently, i is still NULL. When I check, I realise that b is loading from a.dll instead of b.dll.

But I have already make sure b LoadFrom b.dll. Can anyone advise?
 
Use the LoadFile method instead, LoadFrom returns existing assembly if the assembly identity to be loaded is identical.
 
Back
Top