473,545 Members | 1,797 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 2006

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

Similar topics

1
4096
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...
6
8178
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");...
0
1021
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...
0
1392
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...
4
3270
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
1528
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...
0
1371
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...
5
12621
by: Max2006 | last post by:
Hi, What is the limit for memory that a .NET process or AppDomain can use? Thank you, Max
1
2172
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...
0
7487
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...
0
7934
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...
0
7778
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...
1
5349
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...
0
3476
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...
0
3459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1908
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
1
1033
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
731
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...

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.