HighTechTalks DotNet Forums  

Dynamically load a .NET assembly from config file

Dotnet Academic General Discussions microsoft.public.dotnet.academic


Discuss Dynamically load a .NET assembly from config file in the Dotnet Academic General Discussions forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Nelson Xu
 
Posts: n/a

Default Dynamically load a .NET assembly from config file - 01-17-2005 , 08:28 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



Reply With Quote
  #2  
Old   
B S Wootton
 
Posts: n/a

Default Re: Dynamically load a .NET assembly from config file - 01-30-2005 , 09:20 PM






"Nelson Xu" <ningsheng.xu (AT) litton (DOT) c-bass.com> wrote

Quote:
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.

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




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.