By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,967 Members | 1,625 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,967 IT Pros & Developers. It's quick & easy.

using an app.config of a referenced project

P: n/a
TS
I cannot get this to work. I added an app.config to a project i reference
from my web application project (vs 05) but can see no way to access the
settings within it.

the other thing is that I expected this config file (.dll.config) to get put
in my web app's bin folder along with it's .dll file when i did a build, and
that didnt' happen either.

do I have access to the app.config in my project or is it worthless? If so
why can i add an app.config?

thanks
Jun 15 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hi TS,

From your description, you're using some class library projects in a Visual
studio 2005 solution and want to define some data/values in class library's
app.config file so as to reuse them in any upper level application which
reference the class library, correct?

Based on my understanding, for app.config file, .net framework application
only support using app.config file at application level at runtime. In
other words, only an application(exe) can use app.config file, for class
library component(dll), the app.config it reference is the one of the
application which load that class library assemblies. (So there is no
dedicated configuration file for assemby/dll at runtime).

However, why does VS 2005 allow us to add "app.config" file in class
library project? This is due to the following purpose:

In original class library(vs.net 2003), you can not define some values that
be shared with calling application and be able to overwrite/customize them.
Now, you can create setting items in the VS 2005 class library's project
"Settings" collection. To add/manage settings, you go through the following
steps:

**open project properties dialog

**choose "settings" tab in left

** in right panel, you can add multiple settings items(of various type)

After you add items and save it, you can find that the setting items are
actually saved/persisted in the app.config file in the class library
project.

Thus, when you reference this class library in any other application
project, the settings of the project(default value) will be automatically
available, and if you want to override/customize these settings in the
calling application project, you will need to copy the XML configuration
fragment in class library's app.config to your calling application's
app.config (and modify the certain value you want to customize) e.g.

#this is a typical setting persistent content in class library app.config,
you can copy them to calling application's app.config file and customize
any item's value
==============
<configSections>
<sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGrou p, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="ClassLibrary1.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"
/>
</sectionGroup>
</configSections>
<applicationSettings>
<ClassLibrary1.Properties.Settings>
<setting name="ClassLibrarySetting1" serializeAs="String">
<value>setting1 value</value>
</setting>
<setting name="ClassLibrarySetting2" serializeAs="String">
<value>setting2 value</value>
</setting>
</ClassLibrary1.Properties.Settings>
</applicationSettings>
===============================

For your scenario, you can consider define the values you want to share to
calling application in class library's settings collecction. Also, by
default "Settings" collection is marked as "internal", you can manually
change the accessor from "internal" to "public" in the code file so that
calling application can directly acccess them. e.g.

string value1=
ClassLibrary1.Properties.Settings.Default.ClassLib rarySetting1;

Here is a former thread also discussing on the similar question:

http://groups.google.com/group/micro...rk.webservices
/browse_thread/thread/c81a49ae2398f7b8/2f734c0f0d010cd1

Hope this helps some.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

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.

Jun 18 '07 #2

P: n/a
Hi TS,

Have you got any further idea on this thread or does the suggestion in my
last reply helps you some? If there is anything else we can help, please
feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 20 '07 #3

P: n/a
TS
looking into your recommendation, i found the following URL that is supposed
to explain this:
http://msdn.microsoft.com/library/de...tingsCS_RL.asp

unfortunately msdn server can't find this anymore. can you give me the
updated link?

"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:fp**************@TK2MSFTNGHUB02.phx.gbl...
Hi TS,

Have you got any further idea on this thread or does the suggestion in my
last reply helps you some? If there is anything else we can help, please
feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.
>

Jun 20 '07 #4

P: n/a
Thanks for your reply TS,

For the broken reference link, it actually point to the MSDN docuemnt on
the .NET 2.0/VS 2005 project's Application Settings. However, it still
doesn't include description on how to share the settings/properties in
class library project to the host application that reference the class
librarry asembly.

#Application Settings
http://msdn2.microsoft.com/en-us/lib...xh(VS.80).aspx

#Application Settings Overview
http://msdn2.microsoft.com/en-us/library/k4s6c3a0.aspx

My last reply and the messages in those former threads have described this.

If you have any further questions on this or any paricular things unclear,
please feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.



Jun 21 '07 #5

P: n/a
TS
thanks

"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:9m**************@TK2MSFTNGHUB02.phx.gbl...
Thanks for your reply TS,

For the broken reference link, it actually point to the MSDN docuemnt on
the .NET 2.0/VS 2005 project's Application Settings. However, it still
doesn't include description on how to share the settings/properties in
class library project to the host application that reference the class
librarry asembly.

#Application Settings
http://msdn2.microsoft.com/en-us/lib...xh(VS.80).aspx

#Application Settings Overview
http://msdn2.microsoft.com/en-us/library/k4s6c3a0.aspx

My last reply and the messages in those former threads have described
this.
>
If you have any further questions on this or any paricular things unclear,
please feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.
>




Jun 21 '07 #6

P: n/a
Please feel free to let me know if you have anything else wonder on the
related configuration or management approach.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 22 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.