473,809 Members | 2,931 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.net Plugin AppDomain issues.

Situation:
Using C#, ASP.Net

Requirement:
1. ASP.net application with virtual hosting service.
2. Requires a service that will run every predefined frequency in
minutes (2, 30, 100, 10000) defined in web.config and do some data
crunching in the database

How am I doing this?
I would prefer to do this (2) as a windows service but since the
service is with hosting solutions virtual hosting windows service is
out of question.
So, the hack I came up with:
For flexibility sake, the service had to be plugin model. The plugin is
derived from IPlugin (I define this) and has the obvious Run, Pause and
Stop and there is a MessageEvent (event) that is used for messaging to
the plugin framwork to log/exception etc.

Design:
In global.asax I create three static methods, one to startService,
launchService and one to stop (stopService)
When Application_sta rt is called (when app is started) a new thread is
started from startService with method launchService which instantiates
the Plugin framework and picks up all plug-in assemblies and runs them
(calls Run method).

Idea behind this design: a new thread so the current execution is not
affected and continues to run while the new thread runs in background
processing the requirement
Plugin model so whenever a background processing is required I can
create a dll and drop it at a location and that is it.

PROBLEM:
The design's problem, if the application is running I can not "hot"
update plugin assembly while application is running since it is locked.
Through research: new AppDomain

Refer to design.
Now, the new thread creates a new appdomain and creates the plugin
framework that in turn does the Assembly.Load plugin assemblies and so
forth.
Problem, stopService can only abort/join the thread.

Question:
a. How can I stop/pause the plugin assemblies in the new thread?
b. I still can not *hot* swap/update plugin assembly? It is locked.
c. Doing appdomain.unloa d in stopService throws an exception see at the
end number: 1.
d. Will thread.abort /join safe enough to assume that it will call teh
stop?
e. Or is there any way the thread could know that it is being
aborted/joined and it needs to call Stop on all plugins?
f. Does joining/aborting the thread means the new appdomain will be
unloaded/nulled?

Big question:
IS THERE A BETTER WAY this can be implemented?

Thanks in advance.
PS: I will be posting this to ASP.net group as well, so excuse the
cross posting but the subject is such that it belongs to both groups.

Exception 1:
Type: CannotUnloadApp DomainException
Message: AppDomain can not be unloaded because the thread 1918 can not
be unwound out of it.
Stacktrace:

Server stack trace:
at System.AppDomai n.nUnload(Int32 domainInternal, Thread
requestingThrea d)
at System.UnloadWo rker.UnloadWith Lock(AppDomain domain, Thread
requestingThrea d)
at System.UnloadWo rker.Unload(App Domain domain)
at
System.Runtime. Remoting.Messag ing.StackBuilde rSink.PrivatePr ocessMessage(Me thodBase
mb, Object[] args, Object server, Int32 methodPtr, Boolean
fExecuteInConte xt, Object[]& outArgs)
at
System.Runtime. Remoting.Messag ing.StackBuilde rSink.SyncProce ssMessage(IMess age
msg, Int32 methodPtr, Boolean fExecuteInConte xt)

Exception rethrown at [0]:
at System.AppDomai n.Unload(AppDom ain domain)

Dec 26 '06 #1
0 2017

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

Similar topics

1
4129
by: MatthewRoberts | last post by:
Howdy All, I am having difficulty with two-way communication across AppDomains in an attempt to dynamically script applications. Everything works as expected, except when using ByRef parameters. The below explanation is lengthy, but well worth the read. If you can help me, I'd gladly share this code which has greatly helped my development of extensible applications.
6
8202
by: Wal Turner | last post by:
Hi there. There are various snippets on forums regarding issues with AppDomain.Unload and how it just doesnt work. Fortunately, I got it working with the base case, after much fiddling. Consider this 5 line program: AppDomain domain = AppDomain.CreateDomain("MyDomain"); domain.CreateInstance("TempDLL", "TempDLL.Class1"); MessageBox.Show("try deleting file now"); //cant delete file AppDomain.Unload(domain);
0
1034
by: Christian Kaiser | last post by:
I wanted to test my plugin manager and wrote two codes, one for a C# plugin, one for a C++ plugin. The codes are appended at the end. My problem: The C++ class is only inherited from the interface if at least one function is implemeted in the C file. When I implement the class only in the header file (like in the code below), ILDASM shows that the class is NOT inheriting the interface.
0
1407
by: sayalikulkarni | last post by:
Hello all, I have been trying to develop a security plugin for DB2 V8.2 using the GSS APIs. I have a library of GSS APIs implemented by a third party which I am using in my plugin. This plugin is now using the users and groups which belong to the active directory which are accessed by the GSS APIs. My DB2 database is installed in RH enterprise linux 3.0 platform. However I am facing the following issues in the plugin: 1. The server principal...
4
3278
by: zb | last post by:
Situation: Using C#, ASP.Net Requirement: 1. ASP.net application with virtual hosting service. 2. Requires a service that will run every predefined frequency in minutes (2, 30, 100, 10000) defined in web.config and do some data crunching in the database How am I doing this?
1
1536
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... Apologies in advance if this isn't the right place for this question, but I didn't see another group that seemed more appropriate. One of my co-workers is trying to write a C# plugin for a MOM management server and we're having some difficulty getting it to work. When he wrote the plugin, he wrote a little winforms app harness to test it, and we can see the results when the plugin is run this way.
0
1383
by: gerdhub | last post by:
I develop an application that uses a plugin interface, that the hosting application as well as the plugins implement. Each plugin is loaded via: newPlugin.Instance = (IPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); All Plugins are inside a sub directory called "plugins" of the main application. Now I developed one plugin that should implement a network interface, using external dll's from a framework i...
5
12653
by: Max2006 | last post by:
Hi, What is the limit for memory that a .NET process or AppDomain can use? Thank you, Max
1
2183
by: A Popat | last post by:
This is my first question here, so apologies if I have made a mistake. I am developing a collection of small games using WPF with C# but have been having real difficulty in being able to load and unload each game into my main viewer application. The structure of my program is I have a main view application GameViewer.EXE which basically consists of a Frame object to view pages. Each game is a custom class GamePage.CS, shown below: ...
0
9721
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
9600
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,...
1
10375
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10114
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...
1
7651
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
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4331
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
2
3860
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
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.