Groups | Blog | Home
all groups > dotnet academic > january 2005 >

dotnet academic : Dynamically load a .NET assembly from config file


Nelson Xu
1/17/2005 5:28:13 AM
Hi All,
I try to load a .NET assembly at run time from
machine.config file for my Windows Service application.
Here is my VB.NET code:
Dim MyAssembly As [Assembly]
MyAssembly = [Assembly].LoadFrom(AppSettings("PayoffInfo"))
Dim MyTypea As Type = Type.GetType(MyAssembly.FullName)

'Obtain a reference to a method known to exist in assembly.
Dim myMethod As MethodInfo = MyAssembly.GetTypes()
(7).GetMethod("GetGenScreen_LoanNum")
Dim parm() As Object = {101147}
Dim ds As DataSet = myMethod.Invoke(MyTypea, parm)
DataGrid1.DataSource = ds
DataGrid1.DataBind()

Above code work fine. However, I got error when tried to
load another assembly using same code. Here is the error
message:

File or assembly name Radar.LoadAssembly.dll, or one of
its dependencies, was not found.

Thank you in advance !

Nelson

B S Wootton
1/31/2005 2:20:15 AM
[quoted text, click to view]

What is the PayOffInfo item pointing towards? It should be a full assembly
path - not just the filename.

MyAssembly = [Assembly].LoadFrom(AppSettings("PayoffInfo"))
Dim MyTypea As Type = Type.GetType(MyAssembly.FullName)

Ben

AddThis Social Bookmark Button