473,796 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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::mynames pace.Properties .Settings.Defau lt.xxx

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 7325
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

ConfigurationMa nager.AppSettin gs["settingKey "];

You'll need to add a reference to System.Configur ation 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::mynames pace.Properties .Settings.Defau lt.xxx

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*******@yaho o.yabbadabbadoo .comwrote in
message news:D6******** *************** ***********@mic rosoft.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

ConfigurationMa nager.AppSettin gs["settingKey "];

You'll need to add a reference to System.Configur ation 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::myname space.Propertie s.Settings.Defa ult.xxx

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**********@g mail.comwrote in message
news:um******** ******@TK2MSFTN GP02.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::mynames pace.Properties .Settings.Defau lt.xxx

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.co m

"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions .comwrote in
message news:uD******** ******@TK2MSFTN GP02.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**********@g mail.comwrote in message
news:um******** ******@TK2MSFTN GP02.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::myname space.Propertie s.Settings.Defa ult.xxx

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**********@g mail.comдÈëÏûÏ ¢ÐÂÎÅ:um******* *******@TK2MSFT NGP02.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::mynames pace.Properties .Settings.Defau lt.xxx

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
8106
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 any application folder. In particular, this is preventing me from loading the ADO 2.8 type library, but I cannot even force an error by using a malformed GUID. This is my only machine that appears to have this problem. Any ideas?
2
7517
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 namespace definition with class definitions. The book says "C++ has a global anonymous namespace that is similar to Java's global anonymous package. All declarations not explicitly placed in named
10
2645
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 space, I tried to only use parameters and stack space for things which are truely temporary. Instead of passing a pointer to a data structure which should always be populated with data, I have the data structure declared as a global variable and...
4
4670
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 that time. (no reference) When I add these code lines (from global.asax) inside an aspx file, then it works. Because there is a context.
5
3945
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 and then assign this Logon ID (user) a so called User's serverside cookie. 3. My system is configured to accept 1,024 concurrent users, this means that my Global.Asax will host no more than 1,024 Logon IDs and their associated cookies/variables....
15
2517
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
1664
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 a site that will be for members only. They will have to log in to gain access to any of the pages. I am holding the user information in an XML file (there will probably never be a large number of user, so this is efficient enough).
5
4940
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, protected if necessary for thread safety. In C#, of course, there are no global objects. The Program object is static, so cannot contain object instances. While I could store it in my main form pass it around, that seems cumbersome. I could do a...
0
957
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 New DataTable Public g_dbtGeneralInfo As New DataTable Public g_dbtSettings_Locations As New DataTable Public g_dbtSettings_Targets As New DataTable
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9535
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10465
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10021
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9061
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6800
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5453
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4127
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.