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

Dynamically loading Assemblies within a Windows Service

Hi there,

i'm planning on creating a Windows Service, which will have a simple
loop in its OnStart override. In this loop, I dynamically want to load
(job) Assemblies which have a single class implementing a JobInterface
(just an Execute() method). The Service should then execute this method
in a new thread. These Execute() methods won't take more then a couple
of seconds to do what they have to. At the end of the loop in OnStart,
there just will be a Thread.Sleep() causing the Service loop to pause
for some time. After this, the whole loading of assemblies and
executing their Execute() methods will start over again.

Can this be done? i've heard rumors about problems unloading assemblies
again... How do i deal with the service shutdown? Are there any
pitfalls i have to be aware of? I'll be using .net framework 3.0 and c#.

Thanks in advance and greetings from Berlin!

Matthias
--

Jul 16 '08 #1
3 2016
This article describes a whole infrastructure for doing more or less what
you describe:
http://www.eggheadcafe.com/articles/20041204.asp
Peter
"Matthias S." <ma**********************@googlemail.comwrote in message
news:xn***************@news.microsoft.com...
Hi there,

i'm planning on creating a Windows Service, which will have a simple
loop in its OnStart override. In this loop, I dynamically want to load
(job) Assemblies which have a single class implementing a JobInterface
(just an Execute() method). The Service should then execute this method
in a new thread. These Execute() methods won't take more then a couple
of seconds to do what they have to. At the end of the loop in OnStart,
there just will be a Thread.Sleep() causing the Service loop to pause
for some time. After this, the whole loading of assemblies and
executing their Execute() methods will start over again.

Can this be done? i've heard rumors about problems unloading assemblies
again... How do i deal with the service shutdown? Are there any
pitfalls i have to be aware of? I'll be using .net framework 3.0 and c#.

Thanks in advance and greetings from Berlin!

Matthias
--
Jul 16 '08 #2
On Jul 16, 9:17*am, "Matthias S."
<matthias.st_SP_AM_TR_...@googlemail.comwrote:
Hi there,

i'm planning on creating a Windows Service, which will have a simple
loop in its OnStart override.
That is a BAD idea, the onStart should be small and fast. Otherwise
you can get a timeout from the system.
Simply create a thread and do the initialization in that thread.
>
Can this be done? i've heard rumors about problems unloading assemblies
again...
The assemblies CANNOT be unload.
>How do i deal with the service shutdown? Are there any
pitfalls i have to be aware of? I'll be using .net framework 3.0 and c#.
You do not need to reload the assemblies though. you do it once (in
the thread spawned in the onStart.
you can create delegates for the methods you need to call and then use
a timer to execute them time and time again.
Jul 16 '08 #3
The assemblies CANNOT be unload.

You create a new AppDomain though, load them into that, and then dump the
AppDomain?

Jul 17 '08 #4

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

Similar topics

1
by: Doug | last post by:
I am attempting to create a unit test that can switch between calling a method from the web service I created or calling the component that the web service actually calls. So in my unit test...
3
by: lanky_tx | last post by:
Hi All, We have an automated build and test environment using NAnt and Nunit. Some of our assemblies are being strong named by modifying the AssemblyInfo.cs and having csc compile it. Some of...
4
by: Yoni Gibbs | last post by:
Hi, Once an assembly has been downloaded into the GAC, is it possible to execute it locally somehow? e.g. if I download an exe into the GAC, can the client PC simply run this assembly directly,...
1
by: BillyMac | last post by:
Hello I emply a "plug-in" architecture for a .NET Windows service. At OnStart, the service browses for DLL's in in sub-folders and loads them dyanamically using Assembly.LoadFrom() The...
0
by: Verane | last post by:
Hi all, I am working with C# and Visual studio 2003. What I want to do is the following : I have 3 assemblies, let call them A.exe, B.dll and C.dll. I want to dynamically load B and C when A...
7
by: Ollie Riches | last post by:
I am trying to dynamically load an assembly that has a reference to 'Interop.WMEncoderLib.dll' which is a PIA to the windows media player DRM components. When I run the code from a console...
6
by: Dan Dorey | last post by:
I actually have two questions here, but I'll start by giving an outline of what I'm trying to do. I'm building an app with a simple plugin architecture (all in the same app domain). I have each...
2
by: Smithers | last post by:
I have a Windows Forms application that implements a plug-in architecture whereby required assemblies are identified and loaded dynamically. Here are the relevant classes: A = application =...
8
by: =?Utf-8?B?TWFyaw==?= | last post by:
We've got a wierd failure happening on just one machine. One part of our product uses a 3rd party search implementation (dtSearch). DtSearch has a native core (dten600.dll), late-bound, and a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.