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

ASP.net Plugin AppDomain issues.

zb
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 csharp 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
4 3263
"zb" <ze****@gmail.comwrote in message
news:11**********************@i12g2000cwa.googlegr oups.com...
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
Big question:
IS THERE A BETTER WAY this can be implemented?
I have just this requirement for a couple of my clients' live apps. I did
the following:

1) Created a stored procedure to do the data crunching

2) Wrote a Windows service, which is deployed on my local machine, but which
connects remotely to the live SQL Server.

Now, every 30 minutes (configurable), my local service connects to the
remote live database and calls the stored procedure - that's it. Don't have
to worry about any of the problems you're experiencing.
Dec 26 '06 #2
zb
Thanks Mark.

But, your suggestion will not work for me. I do not have access to db
server (I am using MySQL) from outside and keeping any process outside
the hosting environement is a no no.


Mark Rae wrote:
"zb" <ze****@gmail.comwrote in message
news:11**********************@i12g2000cwa.googlegr oups.com...
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
Big question:
IS THERE A BETTER WAY this can be implemented?

I have just this requirement for a couple of my clients' live apps. I did
the following:

1) Created a stored procedure to do the data crunching

2) Wrote a Windows service, which is deployed on my local machine, but which
connects remotely to the live SQL Server.

Now, every 30 minutes (configurable), my local service connects to the
remote live database and calls the stored procedure - that's it. Don't have
to worry about any of the problems you're experiencing.
Dec 27 '06 #3
"zb" <ze****@gmail.comwrote in message
news:11**********************@h40g2000cwb.googlegr oups.com...
I do not have access to db server (I am using MySQL) from outside
So what do you do if you need e.g. to add another table to your MySQL
database...?
Dec 28 '06 #4
zb
There is a web based UI phpMyAdmin! Very powerful tool.

Mark Rae wrote:
"zb" <ze****@gmail.comwrote in message
news:11**********************@h40g2000cwb.googlegr oups.com...
I do not have access to db server (I am using MySQL) from outside

So what do you do if you need e.g. to add another table to your MySQL
database...?
Dec 29 '06 #5

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...
0
by: Rick | last post by:
I am attempting to build a server application that will execute disparate modules provided by any number of sources (internal or customer provided). These 'Plug-Ins' are simply assembly's with...
0
by: Zeya | 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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
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...

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.