473,398 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

dynamic class loading

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
Nov 17 '05 #1
8 2567
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!
Nov 17 '05 #2
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!
Nov 17 '05 #3
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]" <ri******@NOSPAMdevelop.com> ¦b¶l¥ó
news:eg**************@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.
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!

Nov 17 '05 #4
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]" <ri******@NOSPAMdevelop.com> ¦b¶l¥ó
news:eg**************@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.
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!

Nov 17 '05 #5
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.

Nov 17 '05 #6
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.

Nov 17 '05 #7
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

"Richard Blewett [DevelopMentor]" <ri******@NOSPAMdevelop.com> ¦b¶l¥ó
news:OL**************@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.

Nov 17 '05 #8
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

"Richard Blewett [DevelopMentor]" <ri******@NOSPAMdevelop.com> ¦b¶l¥ó
news:OL**************@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.

Nov 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Parag Joshi | last post by:
hi, I am facing a wierd problem with dyanamic class loading. I have a namespace called ETS.DAO which contains my Data Access Object classes. All these classes implement a common interface which...
17
by: Aguilar, James | last post by:
My previous example used the concept of a Shape class heirarchy, so I will continue with that. Suppose I have something like fifty different shapes, and I am trying to instantiate one of them. ...
9
by: Ender | last post by:
I have an application that I would like third party developers to be able to create Plug-ins that will be dynamically loaded into our application to extend functionality. I have utilized the...
4
by: Yan Wang | last post by:
Hi!: I encounter this problem when I do some tests: I have one user control with datalist in it. The ID for datalist is "dlTest". Then in this control code behind class, I declare a protected...
1
by: Robert McLay | last post by:
I have been trying to build python on Cray X1. As far as I can tell it does not support dynamic loading. So the question is: How to build 2.4 without dynamic loading? That is: can I build...
0
by: John Allman | last post by:
Hi all, I'm trying to create a setup which allows a program to request an object using strings and get an object of that type. It appears to be mostly working but i have difficulties if i...
13
by: jerryau | last post by:
Hi, I am trying to dynamically create object instances based on a string class name, and then I need to dynamically set values to these objects, but I have no idea how to do this in C#. Here is...
9
by: pbd22 | last post by:
Hi. This is just a disaster management question. I am using XMLHTTP for the dynamic loading of content in a very crucial area of my web site. Same as an IFrame, but using XMLHTTP and a DIV. I...
11
by: digz | last post by:
Hello, Apologies if this is the wrong group for this question. I want to design an interface , where for a custom functionality , the client writes a new class with the function implementation...
5
by: bearophileHUGS | last post by:
I often use Python to write small programs, in the range of 50-500 lines of code. For example to process some bioinformatics data, perform some data munging, to apply a randomized optimization...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.