473,789 Members | 2,337 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do i create a components at runtime in C#


Hi,

My system uses Mail Client component
the Mail Client can either wrap exchange or pop3\SMTP server functions

in order to do that I declared an abstract named class MailClient
and create two components in two different DLL which derive from MailClient

ExchangeImpl.dl l
Pop3Impl.dll

In the server I define variable

MailClient mailClient;

Now I want to create a specific implementation according to configuration
or user choice

How do I create a specific mail client at run time?

Thanks.

Nov 22 '05 #1
4 4196
Julia <co********@012 .net.il> wrote:
My system uses Mail Client component
the Mail Client can either wrap exchange or pop3\SMTP server functions

in order to do that I declared an abstract named class MailClient
Where does this class live? It should be in another, separate DLL which
both ExchangeImpl and Pop3Impl reference.
and create two components in two different DLL which derive from MailClient

ExchangeImpl.dl l
Pop3Impl.dll

In the server I define variable

MailClient mailClient;

Now I want to create a specific implementation according to configuration
or user choice

How do I create a specific mail client at run time?


Load the appropriate assembly using Assembly.Load, get a reference to
the type itself using Assembly.GetTyp e, and then create an instance of
the type using Activator.Creat eInstance.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #2
"Where does this class live? It should be in another, separate DLL which
both ExchangeImpl and Pop3Impl reference"

It does of course.

"Load the appropriate assembly using Assembly.Load, get a reference to
the type itself using Assembly.GetTyp e, and then create an instance of
the type using Activator.Creat eInstance."
Thanks.

"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
Julia <co********@012 .net.il> wrote:
My system uses Mail Client component
the Mail Client can either wrap exchange or pop3\SMTP server functions

in order to do that I declared an abstract named class MailClient


Where does this class live? It should be in another, separate DLL which
both ExchangeImpl and Pop3Impl reference.
and create two components in two different DLL which derive from MailClient
ExchangeImpl.dl l
Pop3Impl.dll

In the server I define variable

MailClient mailClient;

Now I want to create a specific implementation according to configuration or user choice

How do I create a specific mail client at run time?


Load the appropriate assembly using Assembly.Load, get a reference to
the type itself using Assembly.GetTyp e, and then create an instance of
the type using Activator.Creat eInstance.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 22 '05 #3
BTW can the name of the type which passed to GetType be the Base class name?

"Julia" <co********@012 .net.il> wrote in message
news:u$******** ******@TK2MSFTN GP11.phx.gbl...
"Where does this class live? It should be in another, separate DLL which
both ExchangeImpl and Pop3Impl reference"

It does of course.

"Load the appropriate assembly using Assembly.Load, get a reference to
the type itself using Assembly.GetTyp e, and then create an instance of
the type using Activator.Creat eInstance."
Thanks.

"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
Julia <co********@012 .net.il> wrote:
My system uses Mail Client component
the Mail Client can either wrap exchange or pop3\SMTP server functions

in order to do that I declared an abstract named class MailClient


Where does this class live? It should be in another, separate DLL which
both ExchangeImpl and Pop3Impl reference.
and create two components in two different DLL which derive from MailClient
ExchangeImpl.dl l
Pop3Impl.dll

In the server I define variable

MailClient mailClient;

Now I want to create a specific implementation according to configuration or user choice

How do I create a specific mail client at run time?


Load the appropriate assembly using Assembly.Load, get a reference to
the type itself using Assembly.GetTyp e, and then create an instance of
the type using Activator.Creat eInstance.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Nov 22 '05 #4
Julia <co********@012 .net.il> wrote:
BTW can the name of the type which passed to GetType be the Base
class name?


Well, that would return the base type rather than the actual type, so
when you then called Activator.Creat eInstance it would create an
instance of that base type (if it could). How would it know which
derived type to construct?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #5

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

Similar topics

0
1942
by: Timothy | last post by:
I have developed an application that uses the Office Web Components 2003. This application will be deployed to systems that do not have Office or the Web Components installed. The problem that I am encountering is that if the client does not have Office or the Web Components installed, it produces a System.Runtime.InteropServices.COMException error. I believe what is happening is that all the necessary files needed to use the Web Components...
4
365
by: Julia | last post by:
Hi, My system uses Mail Client component the Mail Client can either wrap exchange or pop3\SMTP server functions in order to do that I declared an abstract named class MailClient and create two components in two different DLL which derive from MailClient ExchangeImpl.dll Pop3Impl.dll
8
6948
by: Larry__Weiss | last post by:
What kind of licensing is needed to be able to use the Microsoft Access product and distribute the applications? In other words, what version of Microsoft Access does a developer need to buy in order to allow distribution of the runtime components without incurring any additional license fees per installation of the runtime? Has this changed very much over the versions of MS Access (especially since Access 2.0)? - Larry Weiss
2
30164
by: Dennis C. Drumm | last post by:
This is a restatement of an earlier post that evidently wasn't clear. I am building a custom MessageBox dialog that has, among other things, a few new button options (yes to all, no to all, etc.) and would like to make the dialog look and act like the standard MessageBox. Therefore, I would like to put in the message section the same type of icons found in the MessageBox dialog, such as MessageBoxIcon.Exclamation. In another post here I had...
9
6527
by: S Wheeler | last post by:
Hi all - I am trying to create an instance of a vb .net class containing a form from unmanaged vc++. The vb.net is a dll. How to do this ? I am trying #import by can't seem to get it quite right. I suspect this is quite simple though. Thanks in advance...
1
1288
by: Wilson | last post by:
Hi, How can I get the list of web components in the page at runtime ? e.g. there is two components in the page : 1. label1 2. textbox1 I want to just the list of the above components.
8
1757
by: Claus | last post by:
Hi all, I am new to C#, .NET and Visual Studio but I have been coding professionally for more than 10 years, so I am not a complete newbe :-) At my work we are now in the process of switching from Borland Delphi to Visual Studio and C#. We have a lot of applications that we do not have time to recode to .NET, so we are planning to do all "new" developments in C#. And this is where my question pop up:
9
2541
by: Laurence | last post by:
Hi there, I have already checked the URL http://www-306.ibm.com/software/data/db2/9/sysreqs.html. There are no Operating System need to install C rumtime environment components other than AIX before installing DB2 Server product. Is it specific for AIX only? By the way, the sentence "If you are installing the Application Development Client, you must have a C compiler to build SQL Stored Procedures". Does it mean for HP-UX and Solaris...
18
2298
by: Angus | last post by:
Hello We have a lot of C++ code. And we need to now create a library which can be used from C and C++. Given that we have a lot of C++ code using classes how can we 'hide' the fact that it is C++ from C compilers? Can we have a C header file which uses the functionality of the C++ files and compile this into a lib file?
0
9661
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9506
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10193
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9978
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9015
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6755
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4087
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2904
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.