469,890 Members | 1,901 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,890 developers. It's quick & easy.

Help using appConfig for application settings

Sai
Hi,

I am using VSTO 2005 Beta for building an excel application. I added
application configuration file to the project (app.config) and it has the
following section in it.
<configuration>
<appSettings>
<add key="serv" value="test" />
</appSettings>
</configuration>

I am unable to get the value for key serv in my workbook startup event.

When I query
System.Configuration.ConfigurationManager.AppSetti ngs("serv").tostring, I
get a message saying that the value is nothig.

When I query the hasKeys property, I get FALSE.

I need help on understanding how I can use an external file to pass certain
parameters to my code.

I would really appreciate any help I can get.

Thanks,

sai
Nov 21 '05 #1
4 2916
Sai wrote:
Hi,

I am using VSTO 2005 Beta for building an excel application. I added
application configuration file to the project (app.config) and it has the
following section in it.
<configuration>
<appSettings>
<add key="serv" value="test" />
</appSettings>
</configuration>

I am unable to get the value for key serv in my workbook startup event.

When I query
System.Configuration.ConfigurationManager.AppSetti ngs("serv").tostring, I
get a message saying that the value is nothig.

When I query the hasKeys property, I get FALSE.

I need help on understanding how I can use an external file to pass certain
parameters to my code.

I would really appreciate any help I can get.

Thanks,

sai


Is it really named app.config? It has to be named <Enter Full
Application Name>.Config

Chris
Nov 21 '05 #2
Hi Sai,

I created a test VSTO2005 project named "Excel_Config" and was able to
retrieve a setting from the configuration file by naming the configuration
file "Excel_Config.dll.config" and placing it in the debug directory.

As a reference I've included the XML for the my configuration file below.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Name" value="Bob"/>
</appSettings>
</configuration>

Using the code below I was able to retrieve the value stored in the "Name"
key.

Dim setting As String
setting = System.Configuration.ConfigurationSettings.AppSett ings("Name")
MessageBox.Show(setting)
Hope this helps!

Regards,

Ken Laws
MSFT
This posting is provided "AS IS" with no warranties, and confers no rights.

For more information regarding Visual Studio Tools for Office 2005:

Best of Blogs: Visual Studio 2005 Tools for Office
http://msdn.microsoft.com/library/de...sto2005_ta.asp

Visual Studio Tools for Office Forum
http://forums.microsoft.com/msdn/Sho...spx?ForumID=16

Visual Studio Tools for the Microsoft Office System
http://msdn.microsoft.com/office/und...o/default.aspx

"Sai" wrote:
Hi,

I am using VSTO 2005 Beta for building an excel application. I added
application configuration file to the project (app.config) and it has the
following section in it.
<configuration>
<appSettings>
<add key="serv" value="test" />
</appSettings>
</configuration>

I am unable to get the value for key serv in my workbook startup event.

When I query
System.Configuration.ConfigurationManager.AppSetti ngs("serv").tostring, I
get a message saying that the value is nothig.

When I query the hasKeys property, I get FALSE.

I need help on understanding how I can use an external file to pass certain
parameters to my code.

I would really appreciate any help I can get.

Thanks,

sai

Nov 21 '05 #3
Sai,

Why don't you use Settings Designer to create setting. here are some
example steps

1. create a VB window Application
2. Open Settings Designer (Solution Explorer-> My Project -> Setting Tab)
3. Add your setting (Name='name', Value = 'bob')
Note: app.config file is generated
4. to access the setting value, you can use 'My.Setting.Name'

For more information, you can search Help under topic 'Application Setting'

Good Luck,

-jack

Nov 21 '05 #4
Hello say,

in VSTO 2005 there exists an Settings.settings under your Project Properties.
this reflects your settings in the app.config file and make it easy to read
and write.

in Sourcecode you can acces this settings like this:

Properties.Settings settings = new Properties.Settings();
string someSetting = settings.<NameOfYourSettingHere>;

Hope this helps,

Greets, Helmut

--
Helmut Obertanner
Technical Consultant
Softwaredevelopment
DATALOG Software AG | Zschokkestr. 36 | D-80687 Munich

.... and IT works!

"Sai" wrote:
Hi,

I am using VSTO 2005 Beta for building an excel application. I added
application configuration file to the project (app.config) and it has the
following section in it.
<configuration>
<appSettings>
<add key="serv" value="test" />
</appSettings>
</configuration>

I am unable to get the value for key serv in my workbook startup event.

When I query
System.Configuration.ConfigurationManager.AppSetti ngs("serv").tostring, I
get a message saying that the value is nothig.

When I query the hasKeys property, I get FALSE.

I need help on understanding how I can use an external file to pass certain
parameters to my code.

I would really appreciate any help I can get.

Thanks,

sai

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Brian Conway | last post: by
3 posts views Thread by Kris van der Mast | last post: by
12 posts views Thread by Kevin Farless | last post: by
13 posts views Thread by Siegfried Heintze | last post: by
1 post views Thread by girthyvhf | last post: by
4 posts views Thread by Brad Isaacs | last post: by
4 posts views Thread by =?Utf-8?B?Z3Jhenph?= | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.