HighTechTalks DotNet Forums  

dynamically loading assemblies

Dotnet Framework (CLR) microsoft.public.dotnet.framework.clr


Discuss dynamically loading assemblies in the Dotnet Framework (CLR) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
jas singh via .NET 247
 
Posts: n/a

Default dynamically loading assemblies - 06-07-2005 , 01:51 PM






i want to dynamically load .dll files and then get value of a satic property. i am doing this but getting an error:

Assembly asm = Assembly.LoadFrom(dllPath);
Type type = asm.GetType();

PropertyInfo propertyInfo = type.GetProperty("info");

Info info = (Info)propertyInfo.GetValue(null,null);

info is the name of the static property. but when i do GetProperty the propertyInfo object is undefined.
--------------------------------
From: jas singh

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>p2KyQgVZ8kG5rkJgXhmHgA==</Id>

Reply With Quote
  #2  
Old   
Jon Skeet [C# MVP]
 
Posts: n/a

Default Re: dynamically loading assemblies - 06-07-2005 , 02:49 PM






jas singh via .NET 247 <anonymous (AT) dotnet247 (DOT) com> wrote:
Quote:
i want to dynamically load .dll files and then get value of a satic
property. i am doing this but getting an error:

Assembly asm = Assembly.LoadFrom(dllPath);
Type type = asm.GetType();

PropertyInfo propertyInfo = type.GetProperty("info");

Info info = (Info)propertyInfo.GetValue(null,null);

info is the name of the static property. but when i do GetProperty
the propertyInfo object is undefined.
You're using asm.GetType, which will always be typeof(Assembly), which
won't have your property. You need to get whichever type you're
interested in from the assembly.

--
Jon Skeet - <skeet (AT) pobox (DOT) com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


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.