J
Joey
Hello guys,
I am currently working on a fairly complex asp.net project using C#,
VS2005, and several third-party components. I have a question about
how to remedy a problem with it and maybe about how to redesign it...
Okay, so I originally set things up like this...I have about 50
configuration settings in the form of <appSettings> keys in my
Web.config file. I designed it this way to allow for us to be able to
make changes to the app (with Notepad or something), save the changes,
which would also conveniently automatically reload the website and the
changes.
I then wrote a custom class called WebsiteSettings that has matching
properties and a LoadConfiguration() function for populating them with
the data from the Web.config file (all via calls to
ConfigurationManager.AppSettings.Get()). I wrote the class as static
public with all the matching properties as static.
I then created a Global.asax file and called
WebsiteSettings.LoadConfiguration() in the Application_Start() event
handler. The idea here is, since the class and member properties are
all static, it gets populated and used only once during each
Application_Start(). Having loaded the configuration this way I can
then conveniently access all settings in my code in this
manner...'WebsiteSettings.SomeSetting'.
Everything was working great until the other day when I added some new
settings and started receiving the following runtime error each time I
tried to run the app...
"An unhandled exception of type 'System.StackOverflowException'
occurred in App_Code.gilihxiu.dll".
This app is built as a "Web Site" and not as a regular C# project/
solution. Also, in this scenario I am running it in File-system mode,
not IIS.
Now, I would like to know...
1. What do you guys think about this setup?
2. Can you guys tell me what is causing the StackOverflowException...I
suspect maybe I am just trying to stick too much data in my static
class?
3. Can I make the current setup work somehow, or do I need to do a
complete redesign...maybe move to a scenario where my class gets
instantiated each time I want to use a setting, instead of always
having everything as static. I REALLY DO NOT want to do that as it
will require a lot of code changes.
Thanks for all of your answers!
I am currently working on a fairly complex asp.net project using C#,
VS2005, and several third-party components. I have a question about
how to remedy a problem with it and maybe about how to redesign it...
Okay, so I originally set things up like this...I have about 50
configuration settings in the form of <appSettings> keys in my
Web.config file. I designed it this way to allow for us to be able to
make changes to the app (with Notepad or something), save the changes,
which would also conveniently automatically reload the website and the
changes.
I then wrote a custom class called WebsiteSettings that has matching
properties and a LoadConfiguration() function for populating them with
the data from the Web.config file (all via calls to
ConfigurationManager.AppSettings.Get()). I wrote the class as static
public with all the matching properties as static.
I then created a Global.asax file and called
WebsiteSettings.LoadConfiguration() in the Application_Start() event
handler. The idea here is, since the class and member properties are
all static, it gets populated and used only once during each
Application_Start(). Having loaded the configuration this way I can
then conveniently access all settings in my code in this
manner...'WebsiteSettings.SomeSetting'.
Everything was working great until the other day when I added some new
settings and started receiving the following runtime error each time I
tried to run the app...
"An unhandled exception of type 'System.StackOverflowException'
occurred in App_Code.gilihxiu.dll".
This app is built as a "Web Site" and not as a regular C# project/
solution. Also, in this scenario I am running it in File-system mode,
not IIS.
Now, I would like to know...
1. What do you guys think about this setup?
2. Can you guys tell me what is causing the StackOverflowException...I
suspect maybe I am just trying to stick too much data in my static
class?
3. Can I make the current setup work somehow, or do I need to do a
complete redesign...maybe move to a scenario where my class gets
instantiated each time I want to use a setting, instead of always
having everything as static. I REALLY DO NOT want to do that as it
will require a lot of code changes.
Thanks for all of your answers!