473,399 Members | 3,919 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,399 software developers and data experts.

global settings question

t f
Hi

Okay this should be a simple one...

In my solution i have 2 projects (one class library and one control
library) - they both share the name default namespace - question is I want
to be able to have settings persist for both librarys but have it contained
in one settings files (this is in the class library as the control library
uses the class library)...

i tried the following in the control library

global::mynamespace.Properties.Settings.Default.xx x

but it is inaccessible due to its protection level... how do i make it so
that the librarys share the same Settings?

is it impossible? if so should i just make a static class which returns the
value?

thanks
t f
Apr 3 '07 #1
5 7308
Try using a regular app.config file (assuming you have an executable that
starts up and reads it. If your settings are simple, you can keep them in the
appSettings section and gain access from either class or control library with

ConfigurationManager.AppSettings["settingKey"];

You'll need to add a reference to System.Configuration assembly.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"t f" wrote:
Hi

Okay this should be a simple one...

In my solution i have 2 projects (one class library and one control
library) - they both share the name default namespace - question is I want
to be able to have settings persist for both librarys but have it contained
in one settings files (this is in the class library as the control library
uses the class library)...

i tried the following in the control library

global::mynamespace.Properties.Settings.Default.xx x

but it is inaccessible due to its protection level... how do i make it so
that the librarys share the same Settings?

is it impossible? if so should i just make a static class which returns the
value?

thanks
t f
Apr 3 '07 #2
t f
Hi

Thanks :-) I will look into it
"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in
message news:D6**********************************@microsof t.com...
Try using a regular app.config file (assuming you have an executable that
starts up and reads it. If your settings are simple, you can keep them in
the
appSettings section and gain access from either class or control library
with

ConfigurationManager.AppSettings["settingKey"];

You'll need to add a reference to System.Configuration assembly.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"t f" wrote:
>Hi

Okay this should be a simple one...

In my solution i have 2 projects (one class library and one control
library) - they both share the name default namespace - question is I
want
to be able to have settings persist for both librarys but have it
contained
in one settings files (this is in the class library as the control
library
uses the class library)...

i tried the following in the control library

global::mynamespace.Properties.Settings.Default.x xx

but it is inaccessible due to its protection level... how do i make it so
that the librarys share the same Settings?

is it impossible? if so should i just make a static class which returns
the
value?

thanks
t f

Apr 3 '07 #3
Hi,

As both projects are libraries (which becomes .DLL) you cannot use an
app.config file.

When I have done in escenarios ilke this is to keep the settings in a file
that I expect to be found in the same folder than the dll. You create a
class with static members and constructor, it's the constructor the one that
load & process the file. Now the issue is that you need to manually process
the file yourself. Not a big deal though.

Take a look at opennetcf.org they provide a similar mechanism of Config than
the full framework.

"t f" <th**********@gmail.comwrote in message
news:um**************@TK2MSFTNGP02.phx.gbl...
Hi

Okay this should be a simple one...

In my solution i have 2 projects (one class library and one control
library) - they both share the name default namespace - question is I want
to be able to have settings persist for both librarys but have it
contained in one settings files (this is in the class library as the
control library uses the class library)...

i tried the following in the control library

global::mynamespace.Properties.Settings.Default.xx x

but it is inaccessible due to its protection level... how do i make it so
that the librarys share the same Settings?

is it impossible? if so should i just make a static class which returns
the value?

thanks
t f

Apr 3 '07 #4
Actually, you can use an app.config file. You just have to use the one
that is associated with the EXE (if there is one). There is nothing that
says that libraries can't use application configuration files, it just
doesn't make sense to have a separate file outside of the application
configuration one.

This is actually the preferred method of using config files. Look at
all the application blocks from MS. IIRC, while they use separate files,
they still are referenced to those separate files from the main app.config
file. Having a separate file which stands ^on it's own with nothing
referencing it^ is not a good thing, as it decentralizes the logical
container for your applciation settings.

What developers need to realize is that even though they are developing
libraries in some cases, those libraries ARE NOT THE APPLICATION.
Therefore, don't assume that you should have your own settings. Rather, let
the person who is putting their application together put their settings
where they would most likely expect it, in the app.config file.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.comwrote in
message news:uD**************@TK2MSFTNGP02.phx.gbl...
Hi,

As both projects are libraries (which becomes .DLL) you cannot use an
app.config file.

When I have done in escenarios ilke this is to keep the settings in a file
that I expect to be found in the same folder than the dll. You create a
class with static members and constructor, it's the constructor the one
that load & process the file. Now the issue is that you need to manually
process the file yourself. Not a big deal though.

Take a look at opennetcf.org they provide a similar mechanism of Config
than the full framework.

"t f" <th**********@gmail.comwrote in message
news:um**************@TK2MSFTNGP02.phx.gbl...
>Hi

Okay this should be a simple one...

In my solution i have 2 projects (one class library and one control
library) - they both share the name default namespace - question is I
want to be able to have settings persist for both librarys but have it
contained in one settings files (this is in the class library as the
control library uses the class library)...

i tried the following in the control library

global::mynamespace.Properties.Settings.Default.x xx

but it is inaccessible due to its protection level... how do i make it so
that the librarys share the same Settings?

is it impossible? if so should i just make a static class which returns
the value?

thanks
t f


Apr 3 '07 #5
Hi,

I'v been employing a singleton object in my solution. And the singleton is
added reference to
all the projects ,so projects can share the global settings of singleton
object.

It seems work well.

BUT,someone told me not to use singleton as global setting.
i cannt find what's the reason excactly.

Anyone tell me why? Thx first.

gshzheng
20070404

"t f" <th**********@gmail.comдÈëÏûÏ¢ÐÂÎÅ:um************ **@TK2MSFTNGP02.phx.gbl...
Hi

Okay this should be a simple one...

In my solution i have 2 projects (one class library and one control
library) - they both share the name default namespace - question is I want
to be able to have settings persist for both librarys but have it
contained in one settings files (this is in the class library as the
control library uses the class library)...

i tried the following in the control library

global::mynamespace.Properties.Settings.Default.xx x

but it is inaccessible due to its protection level... how do i make it so
that the librarys share the same Settings?

is it impossible? if so should i just make a static class which returns
the value?

thanks
t f


Apr 4 '07 #6

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

Similar topics

5
by: Dave Anderson | last post by:
I have one IIS 6 machine that seems to ignore global.asa completely. I can't get *anything* to fire -- not Session_OnStart(), not typelib declarations. This is true in the web root as well as in...
2
by: Tony Johansson | last post by:
Hello! I'm reading a book about C++ and there is something that I don't understand so I ask you. Below I have the text from the book and the code from the file where main is located and some...
10
by: Kleenex | last post by:
Reason: I am working on an embedded project which has very limited memory (under 512 bytes, 60 or so of which is stack space), which translates into limited stack space. In order to save on stack...
4
by: Arjen | last post by:
Hi, I load my website settings inside the global.asax file. For this I have to use the context, to get the roles from the current browsing client. The problem is that there is no context at...
5
by: WJ | last post by:
I am attempting to use the Global.Asax to store my user's configuration. Here is the concept: 1. User logs on into the site using Form Authentication. 2. I capture the user Credential, verify it...
15
by: Mark Goldin | last post by:
I have main aspx page with a number of user controls. How can I create a global property that will be visible in every user control? Thanks
14
by: Alan Silver | last post by:
Hello, I have spent ages trawling through Google, looking for information about global functions in ASP.NET and I'm still not clear about the best way to go about this (or not). I am writing...
5
by: dave | last post by:
If I have a class that hold, for instance, user settings that should be accessible to the entire program logic, what is a good paradigm to use? In C++, I would have made it a global object,...
0
by: Radu | last post by:
Hi. In a public module which I have named "MAIN.VB", I use something like this: Public g_strRequestorsPIN As String Public g_strWebSiteLanguage As String Public g_dbtSettings_HeaderInfo As...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.