Common objects between windows app and asp.net app
Author |
Message |
Mark Heimone #1 / 5
|
 Common objects between windows app and asp.net app
Hi, I've written an application that shares a common class module between a windows project, and an asp.net project. I want to a write a configuration class that reads configuration settings from an xml file and contains a complex configuration structure. The configuration is to be read from an xml file and used inside the common class module. The problem is that I would like to read the configuration file only the first time, and then store the information in some sort of in-memory global application store. That way, the next time the class is used, it can just grab the information from the application store. I know that if I was writing strictly for a web app, I could use system.web.httpcontext.current.application. Is there some sort of common application object I can store this information in, and share with both apps? Alternatively, it is less important that I use an application-style object in the windows app. I suppose if there was some way I could tell which application I was in, I could use code like this: if (IamInaWindowsApplication) then ....read configuration directly from XML File elseIf (IamInaWebApp) then ....read configuration from application object end if Thanks, Mark Heimonen Developer Adia Information Management Corporation
|
Sun, 13 Nov 2005 21:35:58 GMT |
|
 |
Rockford Lhotk #2 / 5
|
 Common objects between windows app and asp.net app
You may want to consider using the standard web.config/app.config files and let Microsoft deal with your problem so you don't have to. It is easy enough to create a custom section in the config file, and the .NET framework will automatically take care of caching the data in both the winforms and webforms environments. For more info go here http://msdn.microsoft.com/library/en-us/dnadvnet/html/vbnet04222003.asp Rocky -- Rockford Lhotka Author of 'Expert One-on-One Visual Basic.NET Business Objects'
Quote: > Hi, > I've written an application that shares a common class module between a > windows project, and an asp.net project. I want to a write a configuration > class that reads configuration settings from an xml file and contains a > complex configuration structure. The configuration is to be read from an > xml file and used inside the common class module. The problem is that I > would like to read the configuration file only the first time, and then > store the information in some sort of in-memory global application store. > That way, the next time the class is used, it can just grab the information > from the application store. > I know that if I was writing strictly for a web app, I could use > system.web.httpcontext.current.application. Is there some sort of common > application object I can store this information in, and share with both > apps? > Alternatively, it is less important that I use an application-style object > in the windows app. I suppose if there was some way I could tell which > application I was in, I could use code like this: > if (IamInaWindowsApplication) then > ....read configuration directly from XML File > elseIf (IamInaWebApp) then > ....read configuration from application object > end if > Thanks, > Mark Heimonen > Developer > Adia Information Management Corporation
|
Mon, 14 Nov 2005 01:33:55 GMT |
|
 |
Mark Heimone #3 / 5
|
 Common objects between windows app and asp.net app
I am currently looking at instantiating this configuration class as a singleton pattern. For an example, see http://www.dotnetextreme.com/code/Singleton.asp. Is this a valid approach to my problem? How does declaring a shared object in asp.net work? Is the object shared accross all sessions, or will I run into conflicts using this approach?
Quote: > Hi, > I've written an application that shares a common class module between a > windows project, and an asp.net project. I want to a write a configuration > class that reads configuration settings from an xml file and contains a > complex configuration structure. The configuration is to be read from an > xml file and used inside the common class module. The problem is that I > would like to read the configuration file only the first time, and then > store the information in some sort of in-memory global application store. > That way, the next time the class is used, it can just grab the information > from the application store. > I know that if I was writing strictly for a web app, I could use > system.web.httpcontext.current.application. Is there some sort of common > application object I can store this information in, and share with both > apps? > Alternatively, it is less important that I use an application-style object > in the windows app. I suppose if there was some way I could tell which > application I was in, I could use code like this: > if (IamInaWindowsApplication) then > ....read configuration directly from XML File > elseIf (IamInaWebApp) then > ....read configuration from application object > end if > Thanks, > Mark Heimonen > Developer > Adia Information Management Corporation
|
Mon, 14 Nov 2005 01:32:44 GMT |
|
 |
Mark Heimone #4 / 5
|
 Common objects between windows app and asp.net app
Thanks, We started out using the standard web.config/app.config file solution, but we are targeting a highly configurable application that we can deploy hundreds of sites with a single code base. Using the web.config file was a workable solution, but we are finding it is becoming harder to maintain. We could use the same style of approach with our new config file, but we do not want the system to have to reload the entire configuration into our configuration class structure on each page load. The reason we decided to go to a custom configuration scheme is that we want to provide the ability to add a arbitrary level of custom attributes for each object in our system.
Quote: > You may want to consider using the standard web.config/app.config files and > let Microsoft deal with your problem so you don't have to. > It is easy enough to create a custom section in the config file, and the > .NET framework will automatically take care of caching the data in both the > winforms and webforms environments. > For more info go here > http://msdn.microsoft.com/library/en-us/dnadvnet/html/vbnet04222003.asp > Rocky > -- > Rockford Lhotka > Author of 'Expert One-on-One Visual Basic.NET Business Objects'
> > Hi, > > I've written an application that shares a common class module between a > > windows project, and an asp.net project. I want to a write a > configuration > > class that reads configuration settings from an xml file and contains a > > complex configuration structure. The configuration is to be read from an > > xml file and used inside the common class module. The problem is that I > > would like to read the configuration file only the first time, and then > > store the information in some sort of in-memory global application store. > > That way, the next time the class is used, it can just grab the > information > > from the application store. > > I know that if I was writing strictly for a web app, I could use > > system.web.httpcontext.current.application. Is there some sort of common > > application object I can store this information in, and share with both > > apps? > > Alternatively, it is less important that I use an application-style object > > in the windows app. I suppose if there was some way I could tell which > > application I was in, I could use code like this: > > if (IamInaWindowsApplication) then > > ....read configuration directly from XML File > > elseIf (IamInaWebApp) then > > ....read configuration from application object > > end if > > Thanks, > > Mark Heimonen > > Developer > > Adia Information Management Corporation
|
Mon, 14 Nov 2005 01:47:59 GMT |
|
 |
Mark Heimone #5 / 5
|
 Common objects between windows app and asp.net app
After testing it out, it seems the singleton object is happily passed between sessions in ASP.NET. Is this any different than using the application object?
Quote: > I am currently looking at instantiating this configuration class as a > singleton pattern. For an example, see > http://www.dotnetextreme.com/code/Singleton.asp. Is this a valid approach > to my problem? How does declaring a shared object in asp.net work? Is the > object shared accross all sessions, or will I run into conflicts using this > approach?
> > Hi, > > I've written an application that shares a common class module between a > > windows project, and an asp.net project. I want to a write a > configuration > > class that reads configuration settings from an xml file and contains a > > complex configuration structure. The configuration is to be read from an > > xml file and used inside the common class module. The problem is that I > > would like to read the configuration file only the first time, and then > > store the information in some sort of in-memory global application store. > > That way, the next time the class is used, it can just grab the > information > > from the application store. > > I know that if I was writing strictly for a web app, I could use > > system.web.httpcontext.current.application. Is there some sort of common > > application object I can store this information in, and share with both > > apps? > > Alternatively, it is less important that I use an application-style object > > in the windows app. I suppose if there was some way I could tell which > > application I was in, I could use code like this: > > if (IamInaWindowsApplication) then > > ....read configuration directly from XML File > > elseIf (IamInaWebApp) then > > ....read configuration from application object > > end if > > Thanks, > > Mark Heimonen > > Developer > > Adia Information Management Corporation
|
Mon, 14 Nov 2005 01:56:38 GMT |
|
|
|