473,573 Members | 2,447 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Properties.Sett ings

When using the properties designer to store application wide properties how
do you get this to work across a project group containing an EXE and a
collection of DLLs. I'm using C#.Net 2005. I noticed that the designer
creates and app.config that gets copied to the output directory as a
[programname].exe.config or [dllname].dll.config. In this setup any
Application Scope property that is in the [programname].exe.config file can
be read in from the file and used. My problem is with Application Scope
properties that are in the dlls. Even when I copy the [dllname].dll.config
file to the output directory of the EXE file I can never read in any
application scope parameters from within the dlls. I also tried putting
there settings in the [progname].exe.config file, this also didn't work. Am
I making any sense to anyone? Anyone have any suggestions?

Dave
Jan 23 '07 #1
13 7126
Hi Dave,

Dlls do not use configuration files. If you plan to use Application
Settings from a dll then you must add the settings to the application
configuration file of the EXE that is referencing it. Unfortunately, there
is no way to enforce that users of your dll provide the settings that it
expects in the app's config file or a user settings file, so you have to
handle that contingency by checking for the existence of the properties'
values and either use a hard-coded default or throw an exception if they
aren't present.

An alternative in the 2.0 framework is to create a custom ASP.NET provider
that encapsulates the settings that your dll needs (the provider foundation
works perfectly well in WinForms applications too):

Provider Toolkit
http://msdn2.microsoft.com/en-us/asp.net/aa336558.aspx

For a class library, I prefer to create a custom provider over some
proprietary settings file or Application Settings in most cases.

--
Dave Sexton
http://davesexton.com/blog

"Dave" <Ki************ @community.nosp amwrote in message
news:OV******** *****@TK2MSFTNG P04.phx.gbl...
When using the properties designer to store application wide properties
how
do you get this to work across a project group containing an EXE and a
collection of DLLs. I'm using C#.Net 2005. I noticed that the designer
creates and app.config that gets copied to the output directory as a
[programname].exe.config or [dllname].dll.config. In this setup any
Application Scope property that is in the [programname].exe.config file
can
be read in from the file and used. My problem is with Application Scope
properties that are in the dlls. Even when I copy the
[dllname].dll.config
file to the output directory of the EXE file I can never read in any
application scope parameters from within the dlls. I also tried putting
there settings in the [progname].exe.config file, this also didn't work.
Am
I making any sense to anyone? Anyone have any suggestions?

Dave


Jan 23 '07 #2
Hi Dave,

What type of project you are using to generate the DLL and
"[dllname].dll.config" file? I assume it is Class Library type. By default,
Class Library project type does not contain a Properties.Sett ings, so you
have to explicitly create one in the project property dialog. I assume you
have done it.

Sorry, I am not sure if I understand you completely. What does the
"Applicatio n Scope properties that are in the dlls" mean? Do you mean the
config values you created in the "[dllname].dll.config" file? I can read
them without any problem in the Class Library project. Below is my test
steps:

1. I create a test Winform project and add a Class Library project
2. I open the class library project property dialog and choose "Settings"
tab to explicitly create the "[dllname].dll.config" file for Class Library
project. Then I added a "Applicatio n" type int value with name "testval"
and default value "7".
3. I write a very simple static method in the Class Library project which
add 2 input parameters and the default setting value.

namespace ClassLibrary1
{
public class Class1
{
public static int Add(int a, int b)
{
return a + b +
ClassLibrary1.P roperties.Setti ngs.Default.tes tval;
}
}
}

4. In Winform application project I add the reference to "ClassLibra ry1"
project and write the following code to use it:
private void button1_Click(o bject sender, EventArgs e)
{
MessageBox.Show (ClassLibrary1. Class1.Add(5, 6).ToString());
}

When I run and click the button, I can get the sum value of "18"(5+6+7)
without any problem. If I have misunderstood you, please feel free to tell
me, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 23 '07 #3
Hi Jeffery,

Application Settings may be persisted in a configuration file for a class
library as you've described, however, it's probably worth noting that no
other configuration elements will be loaded by the framework from the class
library's config file. All other configuration settings must be in the
configuration file of the EXE, so two .config files would be required for
the application to run as expected. For this reason, among others, I prefer
to use a provider that can be registered in one place (the EXE's config)
when providing configurable settings for a class library.

With the 2.0 Provider framework you would use an abstract class, which will
provide some level of compile-time checking to ensure that the properties
and methods that provide settings for the class library are at least
implemented by the application. From here, the author of the application
can choose whether to persist the *provided* properties using Application
Settings for the EXE or just use provider settings, which would make more
sense in this case, IMO. That's one config file for normal config settings,
provider settings and even Application Settings with application-scope.

A custom provider provides a contract between the application and the class
library and therefore is more flexible, and only requires a single config
file. Although, using Application Settings is certainly much simpler and
will save time :)

--
Dave Sexton
http://davesexton.com/blog

""Jeffrey Tan[MSFT]"" <je***@online.m icrosoft.comwro te in message
news:2i******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Dave,

What type of project you are using to generate the DLL and
"[dllname].dll.config" file? I assume it is Class Library type. By
default,
Class Library project type does not contain a Properties.Sett ings, so you
have to explicitly create one in the project property dialog. I assume you
have done it.

Sorry, I am not sure if I understand you completely. What does the
"Applicatio n Scope properties that are in the dlls" mean? Do you mean the
config values you created in the "[dllname].dll.config" file? I can read
them without any problem in the Class Library project. Below is my test
steps:

1. I create a test Winform project and add a Class Library project
2. I open the class library project property dialog and choose "Settings"
tab to explicitly create the "[dllname].dll.config" file for Class Library
project. Then I added a "Applicatio n" type int value with name "testval"
and default value "7".
3. I write a very simple static method in the Class Library project which
add 2 input parameters and the default setting value.

namespace ClassLibrary1
{
public class Class1
{
public static int Add(int a, int b)
{
return a + b +
ClassLibrary1.P roperties.Setti ngs.Default.tes tval;
}
}
}

4. In Winform application project I add the reference to "ClassLibra ry1"
project and write the following code to use it:
private void button1_Click(o bject sender, EventArgs e)
{
MessageBox.Show (ClassLibrary1. Class1.Add(5, 6).ToString());
}

When I run and click the button, I can get the sum value of "18"(5+6+7)
without any problem. If I have misunderstood you, please feel free to tell
me, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no
rights.

Jan 23 '07 #4
Jeffrey,

You can retrieve a value using
"ClassLibrary1. Properties.Sett ings.Default.te stval" like you showed in your
example, but if you go to the config file and change it you will realize its
just giving you the default value that you setup in your property designer.
Not the value that you may have manually setup in your filename.dll.co nfig
file.

Dave
""Jeffrey Tan[MSFT]"" <je***@online.m icrosoft.comwro te in message
news:2i******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Dave,

What type of project you are using to generate the DLL and
"[dllname].dll.config" file? I assume it is Class Library type. By
default,
Class Library project type does not contain a Properties.Sett ings, so you
have to explicitly create one in the project property dialog. I assume you
have done it.

Sorry, I am not sure if I understand you completely. What does the
"Applicatio n Scope properties that are in the dlls" mean? Do you mean the
config values you created in the "[dllname].dll.config" file? I can read
them without any problem in the Class Library project. Below is my test
steps:

1. I create a test Winform project and add a Class Library project
2. I open the class library project property dialog and choose "Settings"
tab to explicitly create the "[dllname].dll.config" file for Class Library
project. Then I added a "Applicatio n" type int value with name "testval"
and default value "7".
3. I write a very simple static method in the Class Library project which
add 2 input parameters and the default setting value.

namespace ClassLibrary1
{
public class Class1
{
public static int Add(int a, int b)
{
return a + b +
ClassLibrary1.P roperties.Setti ngs.Default.tes tval;
}
}
}

4. In Winform application project I add the reference to "ClassLibra ry1"
project and write the following code to use it:
private void button1_Click(o bject sender, EventArgs e)
{
MessageBox.Show (ClassLibrary1. Class1.Add(5, 6).ToString());
}

When I run and click the button, I can get the sum value of "18"(5+6+7)
without any problem. If I have misunderstood you, please feel free to tell
me, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no
rights.
>

Jan 23 '07 #5
Thanks for the feedback. I was hoping to not have to do anything as drastic
as creating a provider for a handful of application and user settings.
"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:uV******** ******@TK2MSFTN GP04.phx.gbl...
Hi Dave,

Dlls do not use configuration files. If you plan to use Application
Settings from a dll then you must add the settings to the application
configuration file of the EXE that is referencing it. Unfortunately,
there
is no way to enforce that users of your dll provide the settings that it
expects in the app's config file or a user settings file, so you have to
handle that contingency by checking for the existence of the properties'
values and either use a hard-coded default or throw an exception if they
aren't present.

An alternative in the 2.0 framework is to create a custom ASP.NET provider
that encapsulates the settings that your dll needs (the provider
foundation
works perfectly well in WinForms applications too):

Provider Toolkit
http://msdn2.microsoft.com/en-us/asp.net/aa336558.aspx

For a class library, I prefer to create a custom provider over some
proprietary settings file or Application Settings in most cases.

--
Dave Sexton
http://davesexton.com/blog

"Dave" <Ki************ @community.nosp amwrote in message
news:OV******** *****@TK2MSFTNG P04.phx.gbl...
When using the properties designer to store application wide properties
how
do you get this to work across a project group containing an EXE and a
collection of DLLs. I'm using C#.Net 2005. I noticed that the designer
creates and app.config that gets copied to the output directory as a
[programname].exe.config or [dllname].dll.config. In this setup any
Application Scope property that is in the [programname].exe.config file
can
be read in from the file and used. My problem is with Application Scope
properties that are in the dlls. Even when I copy the
[dllname].dll.config
file to the output directory of the EXE file I can never read in any
application scope parameters from within the dlls. I also tried putting
there settings in the [progname].exe.config file, this also didn't work.
Am
I making any sense to anyone? Anyone have any suggestions?

Dave


Jan 23 '07 #6
Hi Dave,

Yea, I understand, but it's not really all that difficult. Also, at the
same location, you can download this:

Code Template For Building a Provider-Based Feature
http://download.microsoft.com/downlo...sedfeature.msi

HTH

--
Dave Sexton
http://davesexton.com/blog

"Dave" <Ki************ @community.nosp amwrote in message
news:e$******** *****@TK2MSFTNG P06.phx.gbl...
Thanks for the feedback. I was hoping to not have to do anything as
drastic
as creating a provider for a handful of application and user settings.
"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:uV******** ******@TK2MSFTN GP04.phx.gbl...
>Hi Dave,

Dlls do not use configuration files. If you plan to use Application
Settings from a dll then you must add the settings to the application
configuratio n file of the EXE that is referencing it. Unfortunately,
there
>is no way to enforce that users of your dll provide the settings that it
expects in the app's config file or a user settings file, so you have to
handle that contingency by checking for the existence of the properties'
values and either use a hard-coded default or throw an exception if they
aren't present.

An alternative in the 2.0 framework is to create a custom ASP.NET
provider
that encapsulates the settings that your dll needs (the provider
foundation
>works perfectly well in WinForms applications too):

Provider Toolkit
http://msdn2.microsoft.com/en-us/asp.net/aa336558.aspx

For a class library, I prefer to create a custom provider over some
proprietary settings file or Application Settings in most cases.

--
Dave Sexton
http://davesexton.com/blog

"Dave" <Ki************ @community.nosp amwrote in message
news:OV******* ******@TK2MSFTN GP04.phx.gbl...
When using the properties designer to store application wide properties
how
do you get this to work across a project group containing an EXE and a
collection of DLLs. I'm using C#.Net 2005. I noticed that the
designer
creates and app.config that gets copied to the output directory as a
[programname].exe.config or [dllname].dll.config. In this setup any
Application Scope property that is in the [programname].exe.config file
can
be read in from the file and used. My problem is with Application
Scope
properties that are in the dlls. Even when I copy the
[dllname].dll.config
file to the output directory of the EXE file I can never read in any
application scope parameters from within the dlls. I also tried
putting
there settings in the [progname].exe.config file, this also didn't
work.
Am
I making any sense to anyone? Anyone have any suggestions?

Dave




Jan 23 '07 #7
Hi Dave,

Interesting - I didn't realize it was only using the DefaultValue attribute,
but that makes sense. The default ApplicationSett ingsBase provider is the
LocalFileSettin gsProvider, which uses the static configuration methods to
load the application's configuration file for application-scoped settings, I
believe. If the settings is present in the configuration file then the
ApplicationSett ingsBase class will just revert back to using the value in
the DefaultSettingV alueAttribute.

You may be able to implement a custom SettingsProvide r (yep, provider
framework again). I haven't tried it myself but you may be able to extend
the LocalFileSettin gsProvider class to load data from your dll's
configuration file for application-scoped settings. However, if you feel
that that's worth the effort, then a custom provider is probably a better
choice.

Application Settings Architecture
http://msdn2.microsoft.com/en-us/library/8eyb2ct1.aspx

--
Dave Sexton
http://davesexton.com/blog

"Dave" <Ki************ @community.nosp amwrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
Jeffrey,

You can retrieve a value using
"ClassLibrary1. Properties.Sett ings.Default.te stval" like you showed in
your
example, but if you go to the config file and change it you will realize
its
just giving you the default value that you setup in your property
designer.
Not the value that you may have manually setup in your filename.dll.co nfig
file.

Dave
""Jeffrey Tan[MSFT]"" <je***@online.m icrosoft.comwro te in message
news:2i******** ******@TK2MSFTN GHUB02.phx.gbl. ..
>Hi Dave,

What type of project you are using to generate the DLL and
"[dllname].dll.config" file? I assume it is Class Library type. By
default,
>Class Library project type does not contain a Properties.Sett ings, so you
have to explicitly create one in the project property dialog. I assume
you
have done it.

Sorry, I am not sure if I understand you completely. What does the
"Applicatio n Scope properties that are in the dlls" mean? Do you mean the
config values you created in the "[dllname].dll.config" file? I can read
them without any problem in the Class Library project. Below is my test
steps:

1. I create a test Winform project and add a Class Library project
2. I open the class library project property dialog and choose "Settings"
tab to explicitly create the "[dllname].dll.config" file for Class
Library
project. Then I added a "Applicatio n" type int value with name "testval"
and default value "7".
3. I write a very simple static method in the Class Library project which
add 2 input parameters and the default setting value.

namespace ClassLibrary1
{
public class Class1
{
public static int Add(int a, int b)
{
return a + b +
ClassLibrary1. Properties.Sett ings.Default.te stval;
}
}
}

4. In Winform application project I add the reference to "ClassLibra ry1"
project and write the following code to use it:
private void button1_Click(o bject sender, EventArgs e)
{
MessageBox.Show (ClassLibrary1. Class1.Add(5, 6).ToString());
}

When I run and click the button, I can get the sum value of "18"(5+6+7)
without any problem. If I have misunderstood you, please feel free to
tell
me, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
============== =============== =============== ======
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
>ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
============== =============== =============== ======
This posting is provided "AS IS" with no warranties, and confers no
rights.
>>


Jan 23 '07 #8
Thanks for all your input, I appreciate your suggestions.
"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:OF******** ******@TK2MSFTN GP06.phx.gbl...
Hi Dave,

Interesting - I didn't realize it was only using the DefaultValue
attribute,
but that makes sense. The default ApplicationSett ingsBase provider is the
LocalFileSettin gsProvider, which uses the static configuration methods to
load the application's configuration file for application-scoped settings,
I
believe. If the settings is present in the configuration file then the
ApplicationSett ingsBase class will just revert back to using the value in
the DefaultSettingV alueAttribute.

You may be able to implement a custom SettingsProvide r (yep, provider
framework again). I haven't tried it myself but you may be able to extend
the LocalFileSettin gsProvider class to load data from your dll's
configuration file for application-scoped settings. However, if you feel
that that's worth the effort, then a custom provider is probably a better
choice.

Application Settings Architecture
http://msdn2.microsoft.com/en-us/library/8eyb2ct1.aspx

--
Dave Sexton
http://davesexton.com/blog

"Dave" <Ki************ @community.nosp amwrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
Jeffrey,

You can retrieve a value using
"ClassLibrary1. Properties.Sett ings.Default.te stval" like you showed in
your
example, but if you go to the config file and change it you will realize
its
just giving you the default value that you setup in your property
designer.
Not the value that you may have manually setup in your
filename.dll.co nfig
file.

Dave
""Jeffrey Tan[MSFT]"" <je***@online.m icrosoft.comwro te in message
news:2i******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Dave,

What type of project you are using to generate the DLL and
"[dllname].dll.config" file? I assume it is Class Library type. By
default,
Class Library project type does not contain a Properties.Sett ings, so
you
have to explicitly create one in the project property dialog. I assume
you
have done it.

Sorry, I am not sure if I understand you completely. What does the
"Applicatio n Scope properties that are in the dlls" mean? Do you mean
the
config values you created in the "[dllname].dll.config" file? I can
read
them without any problem in the Class Library project. Below is my test
steps:

1. I create a test Winform project and add a Class Library project
2. I open the class library project property dialog and choose
"Settings"
tab to explicitly create the "[dllname].dll.config" file for Class
Library
project. Then I added a "Applicatio n" type int value with name
"testval"
and default value "7".
3. I write a very simple static method in the Class Library project
which
add 2 input parameters and the default setting value.

namespace ClassLibrary1
{
public class Class1
{
public static int Add(int a, int b)
{
return a + b +
ClassLibrary1.P roperties.Setti ngs.Default.tes tval;
}
}
}

4. In Winform application project I add the reference to
"ClassLibra ry1"
project and write the following code to use it:
private void button1_Click(o bject sender, EventArgs e)
{
MessageBox.Show (ClassLibrary1. Class1.Add(5, 6).ToString());
}

When I run and click the button, I can get the sum value of "18"(5+6+7)
without any problem. If I have misunderstood you, please feel free to
tell
me, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach
the
most efficient resolution. The offering is not appropriate for
situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are
best
handled working with a dedicated Microsoft Support Engineer by
contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no
rights.
>


Jan 23 '07 #9
Hi Dave,

Thanks for your feedback!

With your further feedback, I understand your problem much better now.
Based on my understanding, you wanted to read the modified value in the
[dllname].dll.config, however, you find that it will always report the old
default value. If I still misunderstood you, please feel free to tell me,
thanks.

Yes, I can reproduce this behavior. In the DLL class library, if I modify
the value in [dllname].dll.config, I will always get the old default value.
However, if I modify the value in [dllname].dll.config, the Exe code *can*
read the new modified value without any problem. It seems that they 2 have
different behaviors.

Further research shows that Mr Sexton is right, ApplicationSett ingsBase
will always leverage LocalFileSettin gsProvider internally to read the
setting, below is the stack trace I got for LocalFileSettin gsProvider
initalization during debugging:
> System.Configur ation.LocalFile SettingsProvide r.Initialize(nu ll, null) C#
System.Configur ation.Applicati onSettingsBase. Initializer.get () C#

System.Configur ation.Applicati onSettingsBase. CreateSetting({ System.Reflecti o
n.RuntimeProper tyInfo}) C#
System.Configur ation.Applicati onSettingsBase. EnsureInitializ ed() C#
System.Configur ation.Applicati onSettingsBase. Properties.get( ) C#
System.Configur ation.SettingsB ase.GetProperty ValueByName("te stval") C#
System.Configur ation.SettingsB ase.this[string].get() C#
System.Configur ation.Applicati onSettingsBase. GetPropertyValu e("testval")
C#
System.Configur ation.Applicati onSettingsBase. this[string].get() C#
ClassLibrary1.P roperties.Setti ngs.testval.get () C#
ClassLibrary1.C lass1.Add(0x000 00005, 0x00000006) C#
ConfigSettingTe st.Form1.button 1_Click({Text = Cannot evaluate expression
because the code of the current method is optimized.}, {X = 0x00000025 Y =
0x00000021 Button = Left}) C#

As you can see ApplicationSett ingsBase will really create
LocalFileSettin gsProvider internally. While LocalFileSettin gsProvider uses
ClientSettingsS tore to read the settings, see the stack trace below:
> System.Configur ation.ClientSet tingsStore.Read Settings(sectio nName =
"ClassLibrary1. Properties.Sett ings", isUserScoped = false) C#
System.Configur ation.LocalFile SettingsProvide r.GetPropertyVa lues(context,
properties = {System.Configu ration.Settings PropertyCollect ion}) C#
System.Configur ation.SettingsB ase.GetProperti esFromProvider( provider) C#
System.Configur ation.SettingsB ase.GetProperty ValueByName(pro pertyName =
"testval") C#
System.Configur ation.SettingsB ase.this[string].get(propertyNa me) C#

System.Configur ation.Applicati onSettingsBase. GetPropertyValu e(propertyName
= "testval") C#

System.Configur ation.Applicati onSettingsBase. this[string].get(propertyNa me)
C#
ClassLibrary1.P roperties.Setti ngs.testval.get () C#
ClassLibrary1.C lass1.Add(a = 0x00000005, b = 0x00000006) C#
ConfigSettingTe st.Form1.button 1_Click(sender = {Text = Cannot evaluate
expression because the code of the current method is optimized.}, e = {X =
0x0000002f Y = 0x00000029 Button = Left}) C#

While ClientSettingsS tore will always read the *Exe* config file. For
example, ClientSettingsS tore.GetUserCon fig will always
ClientSettingsS tore.ClientSett ingsConfigurati onHost.OpenExeC onfiguration to
open the *Exe* file's config file.
private System.Configur ation.Configura tion GetUserConfig(b ool isRoaming)
{
ConfigurationUs erLevel level1 = isRoaming ?
ConfigurationUs erLevel.PerUser Roaming :
ConfigurationUs erLevel.PerUser RoamingAndLocal ;
return
ClientSettingsS tore.ClientSett ingsConfigurati onHost.OpenExeC onfiguration(le v
el1);
}

So the conclusion is that the ApplicationSett ingsBase will always read the
Exe file configure, instead of DLL config file. Also, the
LocalFileSettin gsProvider document below also confirms that it will
alreadys read from application.exe .config:
http://msdn2.microsoft.com/en-US/lib...localfilesetti
ngsprovider.asp x

In this scenario, if you really wanted to read from the DLL config file, we
have to write a custom provider, thank Mr Sexton for sharing this idea!

Another solution is copying the DLL config file setting into the
application.exe .config.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.


Jan 24 '07 #10

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

Similar topics

4
8717
by: eugenet | last post by:
Hello, I am writing a Windows Forms application using .NET Framework 2.0 and Visual Studio 2005. I would like to use Properties.Settings class to persist a collection of custom objects. For that I am creating a setting called Connections of type System.Collections.ArrayList using the Properties designer in VS.
1
10248
by: randy1200 | last post by:
I have a DLL Winform project. I've double-clicked Settings.settings under Properties, and create the following application setting: Name: MySetting1, Type: string, Scope: Application, Value: c:\TestDocs When I need the MySetting1 value, just use the following in my C# code: string sVal = "WordDocGenDefaultDirectory"; string str =...
4
1738
by: Shak | last post by:
Hi My code looks like the follwing: namespace A.B.C { .... private void foo() { A.B.C.Properties.Settings.Default.Save();
3
2320
by: Steve Long | last post by:
Hello. Can anyone tell me the proper way to save the properties of a user control between design time and run time? So, I've got this user control with the following properties: BarColor1 BarColor2 I can access these properties in the property browser and change the colors. But how to I have those changes persist between design time and...
0
2825
by: =?Utf-8?B?UmljayBHbG9z?= | last post by:
For some unknown reason (user error?), I cannot get a NameValueCollection to persist in the app.config file. Unlike other settings, I cannot get the String Collection Editor GUI to allow my to add/edit any values for a setting with type NameValueCollection. Nor can I get a NameValueCollection to persist to the User Settings via code using...
1
7232
by: =?Utf-8?B?VGVlcmF2ZWU=?= | last post by:
I try to invoke Connection Properties dialog box that Visual Studio 2005 use. The dialog that I said is used in many places such as when developers build connection string in Settings.setting file (http://www.one.co.th/downloads/Settings.settings.png). The Connection Properties dialog box will appear to allow developers to build connection...
7
18207
by: Dom | last post by:
It seems I can't look at the Properties.Settings.Default.xxxx value in the immediate window while I'm in debug mode. If I try, I get the message: "'System.Windows.Forms.PropertyStore' does not contain a definition for 'Settings'" I can still Debug.Print the value in my code. What gives?
2
3611
by: Jan Eliasen | last post by:
Hi I am having some problems reading configuration values from a configuration file, using C# 2.0. I have programmed a Windows Service, and this part goes well - it runs nicely. Now, the Windows Service must call a Web Service every now and then. I have added the web reference, and made it dynamic, so I can change the
3
1377
by: Morten Snedker | last post by:
How do I share a property across classes? For example I'll have three classes: - Settings - Class1 - Class2 Class1 will initiate the class Settings with a New Settings and will followingly set the properties in the class Settings.
0
7747
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...
0
7987
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. ...
1
7740
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8036
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...
0
6361
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...
1
5557
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5262
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...
1
2167
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
1
1269
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.