473,395 Members | 1,471 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,395 software developers and data experts.

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_start 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.unload 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: CannotUnloadAppDomainException
Message: AppDomain can not be unloaded because the thread 1918 can not
be unwound out of it.
Stacktrace:

Server stack trace:
at System.AppDomain.nUnload(Int32 domainInternal, Thread
requestingThread)
at System.UnloadWorker.UnloadWithLock(AppDomain domain, Thread
requestingThread)
at System.UnloadWorker.Unload(AppDomain domain)
at
System.Runtime.Remoting.Messaging.StackBuilderSink .PrivateProcessMessage(MethodBase
mb, Object[] args, Object server, Int32 methodPtr, Boolean
fExecuteInContext, Object[]& outArgs)
at
System.Runtime.Remoting.Messaging.StackBuilderSink .SyncProcessMessage(IMessage
msg, Int32 methodPtr, Boolean fExecuteInContext)

Exception rethrown at [0]:
at System.AppDomain.Unload(AppDomain domain)

Dec 26 '06 #1
0 1997

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

Similar topics

1
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....
6
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...
0
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...
0
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...
4
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)...
1
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...
0
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 =...
5
by: Max2006 | last post by:
Hi, What is the limit for memory that a .NET process or AppDomain can use? Thank you, Max
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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...
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...

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.