473,411 Members | 2,080 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,411 software developers and data experts.

Creating extensible applications with dotnet

I know how to create exe applications in dotnet that use functions
supplied by pre-existing dlls. How do you turn that around?

I want to create an exe program that will be the pre-existing piece.
It's functionality can then be extended (using new dlls) without
re-compiling the exe.

My proposed program is a test sequencer for an industrial control
application. I want the exe to handle common housekeeping functions
(stepping through tests, saving/recalling data, etc.). I want to
implement the actual tests in such a way that they can be
added/removed/changed at a later time without touching the code of the
main exe application.

I guess my question comes down to: What are the mechanics within an EXE
program to call functions in DLLs that don't exist yet?

How do you architect such a program in dotnet? Can anyone direct me with
some helpful links?

Thanks,
Jim Horvath
Dec 21 '07 #1
3 1848
On Dec 21, 7:36 am, Jim Horvath <not_here@no_spam.orgwrote:
I know how to create exe applications in dotnet that use functions
supplied by pre-existing dlls. How do you turn that around?

I want to create an exe program that will be the pre-existing piece.
It's functionality can then be extended (using new dlls) without
re-compiling the exe.

My proposed program is a test sequencer for an industrial control
application. I want the exe to handle common housekeeping functions
(stepping through tests, saving/recalling data, etc.). I want to
implement the actual tests in such a way that they can be
added/removed/changed at a later time without touching the code of the
main exe application.

I guess my question comes down to: What are the mechanics within an EXE
program to call functions in DLLs that don't exist yet?

How do you architect such a program in dotnet? Can anyone direct me with
some helpful links?

Thanks,
Jim Horvath
Jim,

What it sounds like your looking for is a plug-in architecture. There
is a lot of information on this on the web, and it's been discussed in
these groups. So, you might want to do some searches for plug-in's
for .NET. In fact, in .NET 3.5, there is a whole architecture built
into the framework for this very thing.

In previous versions, the way this is normally accomplished is to
define an interface for you plug-ins in a class library, that will be
referenced by the app and the plug-in. Essentially this interface/
base class forms the contract for communication between your
application and your the plug-in library. Then the main application,
will usually look in a sub-directory and load any dll's it finds there
(Assembly.Load) and then use reflection to find all classes that
implement the interface, and create instances of those objects.

Where things become hairy is if you want to be able to unload the
assemblies dynamically or if you want to protect your app from
crashing if a plug-in does something stupid... In that case, you need
to load the plug-in assemblies into their own AppDomain. Sounds easy
on the surface, but deceptively so. the reason is that it's all to
easy to directly reference a type in the assembly, which will then
cause it to be loaded into your main AppDomain. To get around this,
you need to build a class loader (in a separate library), and then use
it as a proxy to all of your other assemblies.

Anyway, none of this gives specifics I know, but it should give you
enough information to find many of the good articles on the subject
out there on the web. And, if you need some sample code, I probably
have some here in C#. I was working on a prototype for a rules engine
that dynamically loaded rules - though it was scrapped when .NET 3.0
came out, since the rules engine built into Windows Workflows fit our
needs. Anyway, I can probably crop out the relevant bits for you :)

--
Tom Shelton
Dec 21 '07 #2
"Tom Shelton" <to*********@comcast.netwrote
>I want to create an exe program that will be the pre-existing piece.
It's functionality can then be extended (using new dlls) without
re-compiling the exe.
System.AddIn, found in the new .Net 3.5 stuff, is exactly what you're
looking for.

A recent MSDN article on the topic is here:
http://msdn.microsoft.com/msdnmag/is.../CLRInsideOut/

The Add-In team's blog can be found here:
http://blogs.msdn.com/clraddins/

--
Chris Mullins
Dec 21 '07 #3
Tom and Chris,

Thank you for your guidance. I can see that this is not quite as simple
as I had hoped, but you gave me exactly what I needed: some reference
material and some keywords to search for.

Thanks again,
Jim Horvath

Tom Shelton wrote:
On Dec 21, 7:36 am, Jim Horvath <not_here@no_spam.orgwrote:
>I know how to create exe applications in dotnet that use functions
supplied by pre-existing dlls. How do you turn that around?

I want to create an exe program that will be the pre-existing piece.
It's functionality can then be extended (using new dlls) without
re-compiling the exe.

My proposed program is a test sequencer for an industrial control
application. I want the exe to handle common housekeeping functions
(stepping through tests, saving/recalling data, etc.). I want to
implement the actual tests in such a way that they can be
added/removed/changed at a later time without touching the code of the
main exe application.

I guess my question comes down to: What are the mechanics within an EXE
program to call functions in DLLs that don't exist yet?

How do you architect such a program in dotnet? Can anyone direct me with
some helpful links?

Thanks,
Jim Horvath

Jim,

What it sounds like your looking for is a plug-in architecture. There
is a lot of information on this on the web, and it's been discussed in
these groups. So, you might want to do some searches for plug-in's
for .NET. In fact, in .NET 3.5, there is a whole architecture built
into the framework for this very thing.

In previous versions, the way this is normally accomplished is to
define an interface for you plug-ins in a class library, that will be
referenced by the app and the plug-in. Essentially this interface/
base class forms the contract for communication between your
application and your the plug-in library. Then the main application,
will usually look in a sub-directory and load any dll's it finds there
(Assembly.Load) and then use reflection to find all classes that
implement the interface, and create instances of those objects.

Where things become hairy is if you want to be able to unload the
assemblies dynamically or if you want to protect your app from
crashing if a plug-in does something stupid... In that case, you need
to load the plug-in assemblies into their own AppDomain. Sounds easy
on the surface, but deceptively so. the reason is that it's all to
easy to directly reference a type in the assembly, which will then
cause it to be loaded into your main AppDomain. To get around this,
you need to build a class loader (in a separate library), and then use
it as a proxy to all of your other assemblies.

Anyway, none of this gives specifics I know, but it should give you
enough information to find many of the good articles on the subject
out there on the web. And, if you need some sample code, I probably
have some here in C#. I was working on a prototype for a rules engine
that dynamically loaded rules - though it was scrapped when .NET 3.0
came out, since the rules engine built into Windows Workflows fit our
needs. Anyway, I can probably crop out the relevant bits for you :)

--
Tom Shelton
Dec 22 '07 #4

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

Similar topics

14
by: anon | last post by:
Does anyone know how many man-hours were used in creating .NET 1.0? I thought it would be an interesting statistic to know. Thanks.
2
by: Gerwin | last post by:
Hi all, I need to implement a extensible application. This application is using different devices (containing sensors, valves, ...) and different modes (measurement1, measurement2, ...). Target...
2
by: gkelly | last post by:
What is the best soltions for creating a graphical object in c# for use in a C++ app? - I heard some say you can't create an ActiveX control in dotnet and I have heard others say you can using...
3
by: Seth | last post by:
I have been trying to create a mock httpcontext for the purpose of unit testing. I have a class, Customer, that uses cookies. I have set it up to be able to take a httpcontext as a parameter in...
8
by: Simon Edwards | last post by:
Something thats been bugging me for a while... how do you create a namespace that has many children (namespaces) I.e system.io.blah.blah Iv'e done it by creating a class which contains...
1
by: Al | last post by:
Anyone know why MS says you can't create a COM class with VB.NET to use in other VB.NET projects? (reference the statement at the bottom of the MSDN article ... Walkthrough: Creating COM Objects...
12
by: Mats Lycken | last post by:
Hi, I'm creating a CMS that I would like to be plug-in based with different plugins handling different kinds of content. What I really want is to be able to load/unload plugins on the fly without...
5
by: Joe | last post by:
I have an application which runs in a non-secure environment. I also have an application that runs in a secure environment (both on the same machine). Is there any way to share the session data for...
10
by: brooksr | last post by:
I know VB5/VBA very well but have not used VB to create web pages but need to do so. Can someone explain the purposes and differences between VBScript and VB.NET to create web pages? Also...
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...
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
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
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...
0
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...

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.