473,804 Members | 3,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic AppDomains

I have an application that uses the FileSystemWatch er to monitor for the
"drop" of certain files in a folder. Custom actions are then executed based
on the file name, size, etc.

This application can listen for an unlimited number of files and therefore,
runs an unlimitede number of threads that implement the FileSystemWatch er.

However, if a critical error occurs one of these threads, the whole app
crashes.

Is there a way I can create an AppDomain (therefore, another process) for
each file listener? I guess I am trying to simulate what IIS6 does when you
add an applications to different ApplicationPool s so that the crash of one
will not affect the other.

Can anyone point me in the right place? Thanks.

Shaun
Jan 13 '06 #1
1 1457
Before I forget you might want to create and control a specific object in
the new AppDomain here is the method for that.

To create an instance of the object that will run in the AppDomain. This is
achieved by calling CreateInstance which has 3 overloads.

ObjectHandle hndPoolManager = aDomain.CreateI nstance("myTmpD om",
"myNameSpace.Po olManager");

Where the second param must be the fully-qualified namespace of the
object. Alternatively you can call typeOf(PoolMana ger).ToString() to get it.

If you require to interface with the object to call methods or pass data
back and forth you will need to create a proxy to communicate with the
object as it's not in your current domain. This uses Remoting to marshal the
data between the domains. Fortunately the .Net Framework provides a method
to dynamically create this for you.

(PoolManager)hn dPoolManager.Un wrap();

Alternativly you can accomplish these two methods by just doing the
following:

(PoolManager)aD omain.CreateIns tanceAndUnwrap( .., ..);

- Mike

---------------------------------------------------------------------------------
http://www.cogitar.net "> Cogitar Software. ( http://www.cogitar.net )
http://www.web-dominion.co.uk Web-Dominion. (Web Design and hosting )
http://www.shop-dominion.com (senery landscape picture gallery)
---------------------------------------------------------------------------------

<Mike> wrote in message news:Od******** ********@TK2MSF TNGP12.phx.gbl. ..

To resolve the unexpected exception killing the entire application you can
create a new app dominion and execute the threads in that. If you create a
thread manager in the new AppDominion that creates a limited number of
threads. Then to increase the number of threads (if required) create a new
app dominon. This means if a thread has to be killed it will only affect a
limited number of threads.

So how do you do this? First you need to create the temporary AppDomain

AddDomain aDomain = AppDomain.Creat eDomain("myTmpD om");

If you're going to create a number of these generate a unique name
for each one.

Second you need to load the Assembly (exe/dll) into the new AppDomain

ADomain.Load("F ileSystemWatche r.dll")

This will load an Assembly called FileSystemWatch er.dll (or whatever you
choose to call it), which would contain your thread pool manager and
threads. If something does go wrong you then only need to kill the
temporary domain leaving the other temp domains (if created) and your
primary Application running.

- Mike

---------------------------------------------------------------------------------
http://www.cogitar.net "> Cogitar Software. ( http://www.cogitar.net )
http://www.web-dominion.co.uk Web-Dominion. (Web Design and hosting )
http://www.shop-dominion.com (senery landscape picture gallery)
---------------------------------------------------------------------------------


Jan 13 '06 #2

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

Similar topics

1
1924
by: Daylor | last post by:
hi. i have mult thread vb.net application. it has 30 threads. each thread serves 1 phone caller. the question : is there a reason , to create appdomain for each Phone Service ? meaning 30 appdomains ? or , the purpose for creating another appdomains, is diffrent ?
4
2955
by: Mountain Bikn' Guy | last post by:
I need some advice on this. I am working on a fairly complex calculator app (C#) with lots of functions (and these functions in turn use math functions from an unmanaged C DLL). A calculation takes a lot of time (up to hours), and should run on a separate thread from the one that the GUI uses. The GUI also needs to display various properties for each function (such as parameters that can be set). It does this with property grid and other...
1
1274
by: ASayre | last post by:
I'm currently developing a client that connects to a server and exchanges data with the server back and forth. The client retains the data in specified classes depending on what was received. While adding a plugin type API I ran into the following problem: I want users to be able to dynamically un/re-load their plugins as needed, but without having to restart the client. Searching quickly pointed me to articles on AppDomains. However...
8
2022
by: George Meng | last post by:
I got a tough question: The backgroud for this question is: I want to design an application works like a engine. After release, we can still customize a form by adding a button, and source code for the button. (This is done by the form itself, not by using VS.Net) (button and source code should be a record in database, these information should be retrieve from database when the form shows up) What I want is:
1
2570
by: billr | last post by:
hi there, I hope that someone will be able to shed some light on little old confused me. We are developing an application which will be deployed onto a Terminal Server machine. The application will be used concurrently by multiple users. We have a static object (which as you well know is only static per AppDomain), -I think I've just figured out the answer to my question, but perhaps some confirmation wouldn't go amiss-
8
1703
by: Fred Mertz | last post by:
I'm working towards an MCTS cert and I'm having to learn a bunch of stuff that I doubt I'd stumble across on my own. One such feature of .NET is AppDomains; programatically creating new AppDomains and programmatically loading/unloading assemblies in them. Question: What are some scenarios where I'd want to... 1 - programmatically create or destroy AppDomains 2 - load and unload assemblies in AppDomains?
0
1608
by: kayakyakr | last post by:
I'm working with a set of experiments in a large system that is using AppDomains for isolation and wants to make a call out to an umanaged dll. The test dll has two methods, SetNumber(int num) and GetNumber(), and a global variable. The DllImport and getting and setting the numbers are fine. The problem comes when I make the calls to the libraries from separate AppDomains. Calling SetNumber with 3 different values across 3 different...
3
3760
by: | last post by:
If this is simple, forgive my ignorance, but I'm coming from the CompactFramework where we don't use AppDomains. I did a fair bit of archive searching and couldn't find an answer and I got no responsed in the remoting group after a week, so I'm throwing a little wider net this time. I have a desktop app (FFx 2.0) developed with Studio 05 that loads assemblies in a separate AppDomains from the primary UI. I'd like to be able to hook up...
0
1871
by: jeremyje | last post by:
I would like to create an application where I have many concurrent processes being managed by a monitoring process. Each process that is "managed" will be invoked from an assembly dll (think reflection). I want a way to invoke these processes in parallel utilizing multi-core processors but I'd like to have the protection that AppDomains provide. I was doing some research where I found that there is no true isolation between threads and...
0
8730
by: PRR | last post by:
Here is a code i found on "how to enumerate appdomains in a current process". The original code was posted by Thomas Scheidegger Add the following as a COM reference - ~\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscoree.tlb using mscoree; using System.Runtime.InteropServices;
0
9704
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
10562
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10319
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
9132
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...
1
7608
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6845
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
5508
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4282
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

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.