473,396 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

class / base class help

Hi all,

Ok - I'm going around in circles and would appreciate some help.

I have written a windows service, which up until I tried to be clever was
working well :o)

I have a main class which inherits a base class, I also have a
"configuration" class which stores a load of values read in from an xml file
which I would like to be available at any time (without reading the xml file
again).

My intention was to add my "ApplicationConfiguration.vb" class as an object
in my base class, thus everything that derives from it gets to see the
settings.

My problem being that I have some code in the base class that I would also
like to use in the application configuration class - is only one function
but it writes to the event log and I dont see the point of doubling this
up...

This is where the problem began - I decided it would be best for the
application configuration class to inherited the base class - whooops - and
there we go - .net endless circling and creating more and more instances of
itself until it overflowed....luckily in vs2005 it catches this kinda
stupidity before it happens (2003 didnt!!)...

So, I've now removed the inheritance in the application configuration class,
but I'm left without the function I need...

Can anyone offer me any solutions? A "singleton" was suggested by a
colleague at work, but I hadn't fully explained the problem so I wasn't sure
if that was the way to go - plus I only have a rough idea of what a
singleton is so I'll probably code it all wrong anyway :D

Any help appreciated,

Rob
Nov 19 '05 #1
7 1133
I would suggest taking advantage of the System.Configuration namespace.
There's no need to re-invent the wheel, and every ASP.Net app comes with its
own wheel - the web.config file. You can store all kinds of stuff in there,
and it is not read from the file every time you access it. It is cached in
memory when the application starts.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
A watched clock never boils.

"Rob Meade" <te**************@edaem.bbor> wrote in message
news:LU*******************@text.news.blueyonder.co .uk...
Hi all,

Ok - I'm going around in circles and would appreciate some help.

I have written a windows service, which up until I tried to be clever was
working well :o)

I have a main class which inherits a base class, I also have a
"configuration" class which stores a load of values read in from an xml
file which I would like to be available at any time (without reading the
xml file again).

My intention was to add my "ApplicationConfiguration.vb" class as an
object in my base class, thus everything that derives from it gets to see
the settings.

My problem being that I have some code in the base class that I would also
like to use in the application configuration class - is only one function
but it writes to the event log and I dont see the point of doubling this
up...

This is where the problem began - I decided it would be best for the
application configuration class to inherited the base class - whooops -
and there we go - .net endless circling and creating more and more
instances of itself until it overflowed....luckily in vs2005 it catches
this kinda stupidity before it happens (2003 didnt!!)...

So, I've now removed the inheritance in the application configuration
class, but I'm left without the function I need...

Can anyone offer me any solutions? A "singleton" was suggested by a
colleague at work, but I hadn't fully explained the problem so I wasn't
sure if that was the way to go - plus I only have a rough idea of what a
singleton is so I'll probably code it all wrong anyway :D

Any help appreciated,

Rob

Nov 19 '05 #2
Yes, there is a great ConfigurationSettings / ConfigurationManager (2.0)
class that will do everything for you :)

--

Joshua Mitts
jo****@msn.com

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:%2*****************@TK2MSFTNGP09.phx.gbl...
I would suggest taking advantage of the System.Configuration namespace.
There's no need to re-invent the wheel, and every ASP.Net app comes with
its own wheel - the web.config file. You can store all kinds of stuff in
there, and it is not read from the file every time you access it. It is
cached in memory when the application starts.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
A watched clock never boils.

"Rob Meade" <te**************@edaem.bbor> wrote in message
news:LU*******************@text.news.blueyonder.co .uk...
Hi all,

Ok - I'm going around in circles and would appreciate some help.

I have written a windows service, which up until I tried to be clever was
working well :o)

I have a main class which inherits a base class, I also have a
"configuration" class which stores a load of values read in from an xml
file which I would like to be available at any time (without reading the
xml file again).

My intention was to add my "ApplicationConfiguration.vb" class as an
object in my base class, thus everything that derives from it gets to see
the settings.

My problem being that I have some code in the base class that I would
also like to use in the application configuration class - is only one
function but it writes to the event log and I dont see the point of
doubling this up...

This is where the problem began - I decided it would be best for the
application configuration class to inherited the base class - whooops -
and there we go - .net endless circling and creating more and more
instances of itself until it overflowed....luckily in vs2005 it catches
this kinda stupidity before it happens (2003 didnt!!)...

So, I've now removed the inheritance in the application configuration
class, but I'm left without the function I need...

Can anyone offer me any solutions? A "singleton" was suggested by a
colleague at work, but I hadn't fully explained the problem so I wasn't
sure if that was the way to go - plus I only have a rough idea of what a
singleton is so I'll probably code it all wrong anyway :D

Any help appreciated,

Rob


Nov 19 '05 #3
"Kevin Spencer" wrote ...
I would suggest taking advantage of the System.Configuration namespace.
There's no need to re-invent the wheel, and every ASP.Net app comes with
its own wheel - the web.config file. You can store all kinds of stuff in
there, and it is not read from the file every time you access it. It is
cached in memory when the application starts.


Hi Kevin,

Sorry, I should have explained a little further, part of the solution (the
bit I'm having problems with) is a service, as opposed to being web based,
the config file is installed on to the client machine, it would be
beneficial if this could be then updated later - in addition I'm hoping that
an installer will write values to this file at some stage.

Regards

Rob
Nov 19 '05 #4
"Joshua Mitts" wrote ...
Yes, there is a great ConfigurationSettings / ConfigurationManager (2.0)
class that will do everything for you :)


Hi Joshua,

Thanks for the reply - as per my reply to Kevin, alas this wasn't for a web
based app (not this part anyway) - so I'm reading in an xml file installed
on the client PC.

Regards

Rob
Nov 19 '05 #5
Heck, that shouldn't stop you. Any type of .Net app can use a configuration
file. In your project, add an App.config file. At compile-time it becomes
applicationName.exe.config.

The only difference between them is the configuration sections they use. You
can even create your own custom configuration sections, section groups, the
whole nine yards.

BTW, if this isn't an ASP.Net app, why are you asking here? Just curiouos.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
A watched clock never boils.

"Rob Meade" <ku***************@edaem.bor> wrote in message
news:u6**************@TK2MSFTNGP10.phx.gbl...
"Joshua Mitts" wrote ...
Yes, there is a great ConfigurationSettings / ConfigurationManager (2.0)
class that will do everything for you :)


Hi Joshua,

Thanks for the reply - as per my reply to Kevin, alas this wasn't for a
web based app (not this part anyway) - so I'm reading in an xml file
installed on the client PC.

Regards

Rob

Nov 19 '05 #6
You can still use a .Net configuration file. See my other reply for details.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
A watched clock never boils.

"Rob Meade" <ku***************@edaem.bor> wrote in message
news:um**************@TK2MSFTNGP12.phx.gbl...
"Kevin Spencer" wrote ...
I would suggest taking advantage of the System.Configuration namespace.
There's no need to re-invent the wheel, and every ASP.Net app comes with
its own wheel - the web.config file. You can store all kinds of stuff in
there, and it is not read from the file every time you access it. It is
cached in memory when the application starts.


Hi Kevin,

Sorry, I should have explained a little further, part of the solution (the
bit I'm having problems with) is a service, as opposed to being web based,
the config file is installed on to the client machine, it would be
beneficial if this could be then updated later - in addition I'm hoping
that an installer will write values to this file at some stage.

Regards

Rob

Nov 19 '05 #7
"Kevin Spencer" wrote ...
Heck, that shouldn't stop you. Any type of .Net app can use a
configuration file. In your project, add an App.config file. At
compile-time it becomes applicationName.exe.config.
aye, but the file needs to be installed on the client PC and updated by
either the client or the installer - I didn't think you'd be able to do this
with the web.config / app.config files (security etc).
BTW, if this isn't an ASP.Net app, why are you asking here? Just curiouos.


The solution is part and part - half web / half windows service - being that
it was a generic class question I figured it would be ok - sorry if not.

Regards

Rob
Nov 19 '05 #8

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

Similar topics

8
by: Bryan Parkoff | last post by:
I find an interesting issue that one base class has only one copy for each derived class. It looks like that one base class will be copied into three base classes while derived class from base...
11
by: anongroupaccount | last post by:
What measures should be taken to avoid this sort of thing? class Base { }; class Derived1 : public Base { private: int i, j, k;
4
by: Pupeno | last post by:
Hello, I want to jump over a method in the class hierarchy, that is: If I have class A(object), clas B(A), class C(B) and in C, I want a method to do exactly what A does but not what B does in...
8
by: Jackson | last post by:
I want a class that will determine its base class by the argument passed in. What I am about to write _does_not_work_, but it shows what I am trying to do. class ABC(some_super): def...
5
by: Dennis Jones | last post by:
Hello, I have a couple of classes that look something like this: class RecordBase { }; class RecordDerived : public RecordBase {
5
by: The Cool Giraffe | last post by:
I'm designing an ABC and in connection to that i have run into some "huh!" and "oh...". Let me put it as a list. 1. Since the class will only contain bodies of the methods, only the header file...
8
by: crjjrc | last post by:
Hi, I've got a base class and some derived classes that look something like this: class Base { public: int getType() { return type; } private: static const int type = 0; };
19
by: jan.loucka | last post by:
Hi, We're building a mapping application and inside we're using open source dll called MapServer. This dll uses object model that has quite a few classes. In our app we however need to little bit...
7
by: Yen Kwoon | last post by:
Note: This problem is related to gcc but after some back and forth in group gnu.gcc.help it seems to have morph into more of a c++ specificiation question, hence the transplanting to this group. ...
1
by: Rune Allnor | last post by:
Hi all. I am sure this is an oldie, but I can't find a useful suggestion on how to solve it. I have a class hierarchy of classes derived from a base class. I would like to set up a vector of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.