473,383 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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 3138
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: serge calderara | last post by:
dear all, I have problem accessing section group in my configuration application file. I got an error saying thta I can have only one section ???? here is my application configuration looks...
10
by: Brian Conway | last post by:
I have no idea what is going on. I have a Login screen where someone types in their login information and this populates a datagrid based off of the login. Works great in debug and test through...
3
by: Kris van der Mast | last post by:
Hi, I've created a little site for my sports club. In the root folder there are pages that are viewable by every anonymous user but at a certain subfolder my administration pages should be...
12
by: Kevin Farless | last post by:
Hi all, I'm having trouble viewing any .aspx pages on my hosting company's server. The server is a new box running Windows Server 2003 default installation. I'm the first client to try using...
13
by: Siegfried Heintze | last post by:
I refered the engineer at my hosting service to http://support.microsoft.com/default.aspx?scid=kb;en-us;825738 where he tried to follow the directions there. He said there was no such file:...
1
by: girthyvhf | last post by:
Hello all, I am trying to use the example for encrypting connection strings called: How To: Build And Run the Protected Configuration Provider Example. This is located in VS 2005 help at: ...
4
by: Brad Isaacs | last post by:
I am working with ASP.NET 2.0 and using an SQL Server 2000 database. I am using Visual Studio 2005 and developing on my Local machine. I am working with Login controls ASP.Configuration, I...
4
by: =?Utf-8?B?Z3Jhenph?= | last post by:
Hello If someone can help me with this it would be greatly appreciated. I’m no web service expert but I don't think i'm trying to do anything too special. I think i must be missing something...
6
by: TS | last post by:
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.