473,223 Members | 1,677 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,223 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 2009
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: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.