Thanks for your followup Mats,
So far I also haven't any good idea which can both avoid mutiple appdomain
and also make add-in components load/unload flexibly. How frequently will
those add-in components be changed in your asp.net application? If not very
frequently, you can consider restarting the application when there needs to
change add-in components... But as for manually restarting application
through those tricks I mentioend before( change web.config or private bin
dir's content...), there may exists some delay thing the runtime won't end
the old applicaiton and restart new one right after we make any changes
that will cause restart, it may need some further time to do resource
disposing or finalizing.....
In addition, as for
=============
If I add <probing privatePath="AnotherBin"/> to my .config file and
touch a file there, will the application restart itself then too?
=============
this is not possible, because the ASP.NET's runtime is a particular
customized CLR host, it is forced to use the "bin" as the only private
probing path (no matter what we set in the web.config....) .
Thanks,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Date: Mon, 28 Nov 2005 22:40:03 +0100
| From: Mats Lycken <
[email protected]>
| User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
| X-Accept-Language: en-us, en
| MIME-Version: 1.0
| Subject: Re: Creating a plug-in based WebApp
| References: <
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
<q$vTtW#
[email protected]>
| In-Reply-To: <q$vTtW#
[email protected]>
| Content-Type: text/plain; charset=ISO-8859-1; format=flowed
| Content-Transfer-Encoding: 7bit
| Message-ID: <#
[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 1-1-3-42a.vs.vs.bostream.se 82.182.18.143
| Lines: 1
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:361348
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi, and thanks again for your response, it's really appreciated to get
| help from you.
|
| If I load a plugin assembly which holds the plugin type I have to load
| it into a separate AppDomain to be able to unload it, right?
| The thing is that since I want to inherit CompositeControl so that I can
| simply add it to a PlaceHolders control collection I can't have it in
| another AppDomain since it won't serialize.
| Is there some other way to solve it?
|
| On restarting the webapp I guess I could have a file in my bin-directory
| that I simply "touch" when I want to restart the app.
| Then I can control it from the app itself, although it might be a bad
| idea to let the app have write access to the bin-dir, writing to the
| .config file sounds like a no-no too..
| If I add <probing privatePath="AnotherBin"/> to my .config file and
| touch a file there, will the application restart itself then too?
|
| I was planning on adding caching to solve the overhead involved with
| loading the plugins. Either a "whole-page" cache or just cache the
| output of the plugin based on the parameters that are sent to control
| its output.
|
| Thanks again for your reply, it feels great to be able to discuss this
| with a professional.
|
| Best regards,
| Mats
|
|
| Steven Cheng[MSFT] wrote:
| > Thanks for your response Mats,
| >
| > Regarding on your further quesitons:
| >
| > But I'm not that convinced that it is the best way to do it. Will my
app
| > suffer a lot perfomance wise by this architecture?
| > ================================================
| > Of course, dynamically adding webcontrols will add overhead to the
asp.net
| > runtime at serverside processing. Also, since you add many additional
layer
| > to abstract the "Add-in" /WebControls relationship.... that'll make the
| > application's performance more pressed. I suggest you turn on the Trace
to
| > see how much time a typical page which use your current control/add-in
| > model will consume at serverside processing (normal loading and
postback
| > processing).... Also, I think such application architecture suits
| > intranet application where network bandwith won't be the problem and
the
| > concurrent requests number won't be two high...
| >
| >
| > Btw, which is the best way to restart a webapplication to make it
reload
| > my addins. I would like to initiate the restart myself so that I can
| > minimize the downtime, ie. putting all the files in the correct place
| > and just click "Restart" and the webapp is up and running within a
second.
| > ================================================
| >
| > I'm afraid there is no explicit or standard interfaces for us to
manually
| > restart an asp.net application(appdomain). Restaring is controled by
| > runtime itself whenever there occur some certain incidents or meet some
| > certain points. e.g. when we change the components in private "bin" dir
or
| > modify some critical setting in web.config.....
| >
| > Why not just create and hold those add-in class instances in some
| > application cache , and when you need to update them , just remove them
and
| > create new instances and update the caches ?
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure!
www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| > --------------------
| > | Date: Fri, 25 Nov 2005 11:33:36 +0100
| > | From: Mats Lycken <
[email protected]>
| > | User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
| > | X-Accept-Language: en-us, en
| > | MIME-Version: 1.0
| > | Subject: Re: Creating a plug-in based WebApp
| > | References: <
[email protected]>
| > <
[email protected]>
| > <
[email protected]>
| > <
[email protected]>
| > | In-Reply-To: <
[email protected]>
| > | Content-Type: text/plain; charset=ISO-8859-1; format=flowed
| > | Content-Transfer-Encoding: 7bit
| > | Message-ID: <
[email protected]>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: 1-1-3-42a.vs.vs.bostream.se 82.182.18.143
| > | Lines: 1
| > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:360872
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > |
| > | Hi Steven,
| > | I rewrote my code some and abandoned the idea of having a separate
| > | AppDomain for the add-ins. What I did instead was to create an object
| > | factory that sits in my primary appdomain and creates instances of my
| > | add-ins for each request. The add-ins are quite lightweight, just
| > | parsing some parameters and loading the correct UserControl.
| > |
| > | The add-in inherits CompositeControl so I can simply do a:
| > | Control userControl =
| > | this.Page.LoadControl(RequestedControlPath);
| > | this.Controls.Add(userControl);
| > | in my add-in to load the userControl. I then do a
| > | Controls.Add(addInObj); on a placeholder object in my page.
| > | Everything is dandy and postback works like a charm.
| > |
| > | But I'm not that convinced that it is the best way to do it. Will my
app
| > | suffer a lot perfomance wise by this architecture?
| > |
| > | Btw, which is the best way to restart a webapplication to make it
reload
| > | my addins. I would like to initiate the restart myself so that I can
| > | minimize the downtime, ie. putting all the files in the correct place
| > | and just click "Restart" and the webapp is up and running within a
second.
| > |
| > | Steven Cheng[MSFT] wrote:
| > | > Hi Mats,
| > | >
| > | > The Mutiple subdomain Add-in architecture is ususally used in many
| > destop
| > | > application, seems not quite common for asp.net scenario. Anyway,
based
| > on
| > | > my understanding, we'll meet the following problem here:
| > | >
| > | > 1. For ASP.NET's page processing, it is request/response based. So
each
| > | > time a request is processed in a server worker thread( page class
and
| > other
| > | > control instances are contructed during this server pipeline....) ,
| > after
| > | > that , all the pages and control instances are destroyed and page
| > content
| > | > being flush to clientside.... (later a new post back to server
cause a
| > new
| > | > worker thread and page structure to be constructed.....). So I
think
| > we
| > | > should not implement those add-ins as control, if so, we'll need to
| > create
| > | > them in each request, and also I don't think ASP.NET page model
will
| > | > support cross appdomain control communication.... So we need to
| > | > implement add-in as separate compent classes which will be loaded
into
| > | > ASP.NET worker process (in separate appdomain ) at startup time .
| > | >
| > | > 2. Then, since we create those Add-in appdomains in asp.net woker
| > process
| > | > (at startup time), what we need to do later is communicating with
those
| > | > addins in the appdomain, this is another hard problem. What I can
get
| > | > currently is creating those add-in instance's proxies at start up
| > | > time(right after they've been created in cross domain) and store
these
| > | > proxy references in a gobal collection (ApplicationState or
Application
| > | > Cache...). Thus, all the later requests can access them in events
| > code....
| > | >
| > | > Anyway, though this is possible, I really feel a bit nervous on it
| > since
| > | > creating multiple sub appdomain in ASP.NET process may make it a
bit
| > | > unstable and cross domain communication will hurt the ASP.NET
runtime
| > | > performance .....
| > | >
| > | > Thanks,
| > | >
| > | > Steven Cheng
| > | > Microsoft Online Support
| > | >
| > | > Get Secure!
www.microsoft.com/security
| > | > (This posting is provided "AS IS", with no warranties, and confers
no
| > | > rights.)
| > | >
| > | >
| > | > --------------------
| > | > | Date: Wed, 23 Nov 2005 19:07:04 +0100
| > | > | From: Mats Lycken <
[email protected]>
| > | > | User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
| > | > | X-Accept-Language: en-us, en
| > | > | MIME-Version: 1.0
| > | > | Subject: Re: Creating a plug-in based WebApp
| > | > | References: <
[email protected]>
| > | > <
[email protected]>
| > | > | In-Reply-To:
<
[email protected]>
| > | > | Content-Type: text/plain; charset=ISO-8859-1; format=flowed
| > | > | Content-Transfer-Encoding: 7bit
| > | > | Message-ID: <
[email protected]>
| > | > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | > | NNTP-Posting-Host: 1-1-3-42a.vs.vs.bostream.se 82.182.18.143
| > | > | Lines: 1
| > | > | Path:
TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| > | > | Xref: TK2MSFTNGXA02.phx.gbl
| > | > microsoft.public.dotnet.framework.aspnet:360511
| > | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > | > |
| > | > | Thanks for the fast reply!
| > | > |
| > | > | I've already done this but it doesn't work for me... the thing is
| > that I
| > | > | want to add my control to a placeholders control collection, then
I
| > need
| > | > | a direct reference to the plugin so that I can add it.
| > | > |
| > | > | My plugin uses .ascx files to display the data and I can't create
an
| > | > | instance of it without having access to the WebForms context (as
I
| > | > | understand it), so I need to add the plugin the usual way,
| > | > | Controls.Add(plugin);
| > | > |
| > | > | (e-mail address removed) wrote:
| > | > | > You can pass the object by reference instead, but as you are
already
| > | > | > inheriting from CompositeControl you can't do this directly,
| > | > | >
| > | > | > You will need to use the delegate pattern here,
| > | > | >
| > | > | > Create an interface that covers all the methods on your plugin,
make
| > | > | > the plugin implement it
| > | > | >
| > | > | > Create another class that inherits from MarshalByRefObject,
make
| > this
| > | > | > object also implement your interface.
| > | > | >
| > | > | > The class (that implements marshalbyrefobject) should have a
| > property
| > | > | > of your plugin type,
| > | > | >
| > | > | > then for the methods that you need to implement (interface
methods)
| > | > | > simply route these to the plugin (via the property)
| > | > | >
| > | > | > a bit long winded but as we can't do multiple inheritence this
is
| > one
| > | > | > way of getting around this,
| > | > | >
| > | > |
| > | > |
| > | >
| > |
| >
|