Ravi Thx for the response: I could not see the file you mentioned to unzip from, so I cannot compare my solution and yours, but I have also played around over the weekend, and here is my solution: (In my limited test environment, it seemed to work 100%)
I create a factory type class with the ability to create instances of all the classes I want to work with from my existing apps. The factory class has a shared function Init on it which will create a new appdomain, and all classes created afterwards by the factory class is created inside this appdomain. A precondition is that the created class (and all the classes exposed as properties of this class) has to be serializable. (Note: I got the basic idea from an earlier mail stream to this mail group) I include the factory class and the calling code ---------- Factory ---------- Imports System.Reflection Public Class clsFactory Inherits MarshalByRefObject Private Shared mobjFactory As clsFactory = Nothing Private mobjSys As XUserCO.clsSystem 'the root class of my external app: The one with the public variables Public Shared Function GetInstance(ByVal pobjdomain As AppDomain) As clsFactory Dim lobjFactory As clsFactory = Nothing If (System.Object.ReferenceEquals(AppDomain.CurrentDomain, pobjdomain)) Then lobjFactory = GetInstance() Else Dim lobjInner As New clsInnerFactory() lobjInner = pobjdomain.CreateInstanceAndUnwrap(Reflection.Assembly.GetExecutingAssembly( ).FullName, lobjInner.GetType.FullName) lobjFactory = lobjInner.GetInstance() End If Return lobjFactory End Function Private Shared Function getInstance() As clsFactory mobjFactory = New clsFactory() Return mobjFactory End Function Private Class clsInnerFactory Inherits MarshalByRefObject Public Function GetInstance() As clsFactory Return clsFactory.GetInstance() End Function End Class Public Shared Function Init(ByVal pstrName As String) As AppDomain Return AppDomain.CreateDomain(pstrName) End Function Public Property Sys() As XUserCO.clsSystem' Exposing the root object which uses public variables Get If mobjSys Is Nothing Then mobjSys = XUserCO.clsSystem.GetInstance Return mobjSys End Get Set(ByVal Value As XUserCO.clsSystem) mobjSys = Value End Set End Property End Class -------------- Calling the factory Dim host1 As AppDomain = clsFactory.Init("Test 1") Dim s1 As clsFactory = clsFactory.GetInstance(host1) Dim host2 As AppDomain = clsFactory.Init("Second one") Dim s2 As clsFactory = clsFactory.GetInstance(host2) s1.UserID = 1 s2.UserID = 2 'If running in the same appdomain, S1.userid will always be equal to S2.userid: now it aint lint = s1.UserID lint = s2.UserID ------------------- Comments appreciated JC Oberholzer |-----Original Message----- |From: Ravi Pazhani [mailto:[EMAIL PROTECTED] |Sent: 16 June 2003 03:07 PM |To: [EMAIL PROTECTED] | |quick & dirty one! | |create a directory customcontextclient under \inetpub\wwwroot |extract the files. |set up a site under defaultwebsite named "customcontextclient" and point to |\inetpub\wwwroot\customcontextclient folder. | | |open the sln file and run. due to lack of time i am not able create a |detailed documentation. |web config file contains necessary entries to add the |"MyCustomContextModule". | | |for simplicity i have show only one module with all the .net classes in it. |mutiple httpmodules can be used to create different services and add it to |"MyCustomContext". |in that case "MyCustomContextModule" becomes the primary module and should |appear as first item in web config <httpmodules> section. | | |HTH |Ravi | | |>From: Edmund Maher <[EMAIL PROTECTED]> |>Reply-To: "Moderated discussion of advanced .NET topics." |><[EMAIL PROTECTED]> |>To: [EMAIL PROTECTED] |>Subject: Re: [ADVANCED-DOTNET] Process Isolation in ASP.NET |>Date: Fri, 13 Jun 2003 13:59:02 -0400 |> |>Ravi- |> This sounds interesting, could you give an example? I'm trying |>to develop a logging mechanism and your idea sounds like it would be an |>approach I could take... |> |>Tks- |>ed |> |>-----Original Message----- |>From: Moderated discussion of advanced .NET topics. |>[mailto:[EMAIL PROTECTED] On Behalf Of Ravi Pazhani |>Sent: Friday, June 13, 2003 12:55 PM |>To: [EMAIL PROTECTED] |>Subject: Re: [ADVANCED-DOTNET] Process Isolation in ASP.NET |> |> |>One common approach is to create custom HttpModule and inject a custom |>context to the application. This custom context can host all the |>services you want to provide to the application. All the services that |>are embedded inyour context are available to all the classes of your asp |>.net app. This approach not only provides enough isoloation from the |>application code but also easily configurable. |> |>HTH |> |>Ravi |> |> |> |> |> >From: JC Oberholzer <[EMAIL PROTECTED]> |> >Reply-To: "Moderated discussion of advanced .NET topics." |> ><[EMAIL PROTECTED]> |> >To: [EMAIL PROTECTED] |> >Subject: [ADVANCED-DOTNET] Process Isolation in ASP.NET |> >Date: Fri, 13 Jun 2003 10:10:13 -0400 |> > |> >I need some help on the following: My class library (dll) uses a |> >variable declared as public in order to share central information to |> >all classes in the application (such as connectionstring etc). This |> >works fine with WinForm apps using the class library, as one instance |> >of the public variable exists per appdomain. |> > |> >I need to use the same class library for an ASP app as well, and this |> >is where I need some help : How to get the ASP app to instantiate one |> >instance of my public variable per user session: |> > |> >I have played around a lot with createing serializable classes and |> >creating my own appdomains, but my solutions are not very ellegant, adn |> |> >I reckon I can surely not be the only guy to have run into this issue. |> |> >? Is there any way to just "configure" my way out of this? (would be |> >the first prize), or any other relatively easy way to get around this |> >issue? |> > |> >Thx |> > |> >JC Oberholzer |> > |> >-- Technical info: Each of my class libraries always has a class |> >clsSystem, with private constructure and a shared function GetInstance |> >which is used to ensure I have only one onstance of my public variable |> >in the app |> > |> >public class clsSystem |> >.. |> > Public Shared Function GetInstance () as clsSystem |> |>_________________________________________________________________ |>Protect your PC - get McAfee.com VirusScan Online |>http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 | |_________________________________________________________________ |STOP MORE SPAM with the new MSN 8 and get 2 months FREE* |http://join.msn.com/?page=features/junkmail The views expressed in this e-mail are, unless otherwise stated, those of the author and not of SDT or its management. The information is confidential and is intended solely for the addressee. All reasonable steps are taken to ensure the accuracy, integrity and confidentiality of information. No liability or responsibility is accepted if information is corrupted or does not reach its intended destination. This email message has been scanned for viruses and cleared.