Home All Groups Group Topic Archive Search About
Author
26 Mar 2005 9:55 AM
KC Eric
Hi all,

If someone has compiled a dll for the some classes,
and I want to use the dll in another project, how can I know the class
available in that dll file?

Thanks!

KC Eric


--
-> ¹ª¨¬·F«l¡A¤Oª§¤W´å¡A¦h§Ö¦n¬Ù¦a«Ø³]²z·QFYP¥D¸q
-> °í¨M¿í±qÄP­ô¥|¶µªí­z¡A¥þ­±¸¨¹ê¤jÄPª÷Á`¸ô½u¡A¨«¦V¥|­Óª«¥óªì©l¤Æ
-> ¯R¿Ë®Q¿Ë³£¤£¤Îª÷ÄP­ô¿Ë XDDD
-> To be energetic to strive for the best. To build our FYP idealism in a
flourishing, rapid, perfect and efficient manner.
-> To firmly adhere to Pango's Four Statements. To comprehensively implement
The Giant Pango's Great Scheme. To stride forward to the Initialization of
The Four Objects.
-> Parents are not as close as Pango. XDDD

Author
26 Mar 2005 10:21 AM
Richard Blewett [DevelopMentor]
Assembly a = Assembly.LoadFrom(<codebase of assembly>);
foreach( Type t in a.GetTypes() )
{
if( a.IsClass )
{
// Do stuff to class such as
object o = a.CreateInstance(t.FullName);
}
}

Obviously if you are interested in all types not just classes you can omit the if.

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

   Hi all,

If someone has compiled a dll for the some classes,
and I want to use the dll in another project, how can I know the class
available in that dll file?

Thanks!
Author
26 Mar 2005 2:48 PM
KC Eric
Thanks!

How about even the name of the dll file is not provided?

We only know the dll file is in a certain directory, say c:\temp,  but the
name of dll is not known.

KC Eric

--
-> ¹ª¨¬·F«l¡A¤Oª§¤W´å¡A¦h§Ö¦n¬Ù¦a«Ø³]²z·QFYP¥D¸q
-> °í¨M¿í±qÄP­ô¥|¶µªí­z¡A¥þ­±¸¨¹ê¤jÄPª÷Á`¸ô½u¡A¨«¦V¥|­Óª«¥óªì©l¤Æ
-> ¯R¿Ë®Q¿Ë³£¤£¤Îª÷ÄP­ô¿Ë XDDD
-> To be energetic to strive for the best. To build our FYP idealism in a
flourishing, rapid, perfect and efficient manner.
-> To firmly adhere to Pango's Four Statements. To comprehensively implement
The Giant Pango's Great Scheme. To stride forward to the Initialization of
The Four Objects.
-> Parents are not as close as Pango. XDDD

"Richard Blewett [DevelopMentor]" <richardb@NOSPAMdevelop.com> ¦b¶l¥ó
news:egA1H2eMFHA.3328@TK2MSFTNGP14.phx.gbl ¤¤¼¶¼g...
> Assembly a = Assembly.LoadFrom(<codebase of assembly>);
>  foreach( Type t in a.GetTypes() )
>  {
>  if( a.IsClass )
>  {
>  // Do stuff to class such as
>  object o = a.CreateInstance(t.FullName);
>  }
>  }
>
>  Obviously if you are interested in all types not just classes you can
omit the if.
Show quote
>
>  Regards
>
>  Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
>
>    Hi all,
>
>  If someone has compiled a dll for the some classes,
>  and I want to use the dll in another project, how can I know the class
>  available in that dll file?
>
>  Thanks!
>
>
Author
26 Mar 2005 3:41 PM
Richard Blewett [DevelopMentor]
foreach( string fileName in Directory.GetFiles(<directory path>, "*.dll")
{
try
{
Assembly a = Assembly.LoadFrom(fileName);
// etc
}
catch( FileLoadException e)
{
// deal with the fact that some of the dlls may not be assemblies
}
}

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

   Thanks!

How about even the name of the dll file is not provided?

We only know the dll file is in a certain directory, say c:\temp, but the
name of dll is not known.
Author
26 Mar 2005 4:16 PM
KC Eric
Really thanks so much !

KC Eric

--
-> ¹ª¨¬·F«l¡A¤Oª§¤W´å¡A¦h§Ö¦n¬Ù¦a«Ø³]²z·QFYP¥D¸q
-> °í¨M¿í±qÄP­ô¥|¶µªí­z¡A¥þ­±¸¨¹ê¤jÄPª÷Á`¸ô½u¡A¨«¦V¥|­Óª«¥óªì©l¤Æ
-> ¯R¿Ë®Q¿Ë³£¤£¤Îª÷ÄP­ô¿Ë XDDD
-> To be energetic to strive for the best. To build our FYP idealism in a
flourishing, rapid, perfect and efficient manner.
-> To firmly adhere to Pango's Four Statements. To comprehensively implement
The Giant Pango's Great Scheme. To stride forward to the Initialization of
The Four Objects.
-> Parents are not as close as Pango. XDDD

Show quote
"Richard Blewett [DevelopMentor]" <richardb@NOSPAMdevelop.com> ¦b¶l¥ó
news:OLRe3ohMFHA.2680@TK2MSFTNGP09.phx.gbl ¤¤¼¶¼g...
> foreach( string fileName in Directory.GetFiles(<directory path>, "*.dll")
>  {
>  try
>  {
>  Assembly a = Assembly.LoadFrom(fileName);
>  // etc
>  }
> catch( FileLoadException e)
>  {
>  // deal with the fact that some of the dlls may not be assemblies
>  }
>  }
>
>  Regards
>
>  Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
>
>    Thanks!
>
>  How about even the name of the dll file is not provided?
>
>  We only know the dll file is in a certain directory, say c:\temp, but the
>  name of dll is not known.
>

AddThis Social Bookmark Button