473,385 Members | 1,973 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,385 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 2563
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.