Help using appConfig for application settings

S

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.AppSettings("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
 
C

Chris

Sai said:
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.AppSettings("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
 
G

Guest

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.AppSettings("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/d...n-us/odc_2003_ta/html/odc_landvsto2005_ta.asp

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

Visual Studio Tools for the Microsoft Office System
http://msdn.microsoft.com/office/understanding/vsto/default.aspx
 
J

Jack hu

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
 
G

Guest

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top