473,397 Members | 2,116 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,397 software developers and data experts.

Configuration files in a shared add-in component

QT
Hi.

Is it possible to use configuration files with a shared add-in component? I have added one to my solution for the add-in, but I can't pick up the values from my config file.

If my component's name is MyComponent.dll, my config file is named MyComponent.config.

Here is the file contents:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<addkey="data source" value="MyServer\MyShare" />
<addkey="initial catalog" value="MyDB" />
<addkey="security" value="false" />
<addkey="userid" value="myuserid" />
<addkey="password" value="mypassword" />
</appSettings>
</configuration>

Here is the code I've tried from a customized class object method within my component:
strDatasrc = System.Configuration.ConfigurationSettings.AppSett ings("data source")
strInitcatalog = System.Configuration.ConfigurationSettings.AppSett ings("initial catalog")
strSecurity = ConfigurationSettings.AppSettings("mysection/security")
strUserid = ConfigurationSettings.AppSettings("userid")
strPassword = ConfigurationSettings.AppSettings("password")

The values of my string variables stay as "Nothing".

I also tried using configuration sections, but no luck with that either.
--
Thanks!
QT
Nov 20 '05 #1
1 1377
QT,

config files are create per application domain (executable). Therefore, you
will not be able to use it as you are trying to. I did some quick research
and I found an article showing how to create a class that you can use to
overcome this limitation. I have not tested it.

http://www.theserverside.net/develop...hread_id=25076

Telmo Sampaio
"QT" <QT@discussions.microsoft.com> wrote in message
news:B4**********************************@microsof t.com...
Hi.

Is it possible to use configuration files with a shared add-in component? I have added one to my solution for the add-in, but I can't pick up the
values from my config file.
If my component's name is MyComponent.dll, my config file is named MyComponent.config.
Here is the file contents:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<addkey="data source" value="MyServer\MyShare" />
<addkey="initial catalog" value="MyDB" />
<addkey="security" value="false" />
<addkey="userid" value="myuserid" />
<addkey="password" value="mypassword" />
</appSettings>
</configuration>

Here is the code I've tried from a customized class object method within my component: strDatasrc = System.Configuration.ConfigurationSettings.AppSett ings("data source") strInitcatalog = System.Configuration.ConfigurationSettings.AppSett ings("initial catalog") strSecurity = ConfigurationSettings.AppSettings("mysection/security")
strUserid = ConfigurationSettings.AppSettings("userid")
strPassword = ConfigurationSettings.AppSettings("password")

The values of my string variables stay as "Nothing".

I also tried using configuration sections, but no luck with that either.
--
Thanks!
QT

Nov 20 '05 #2

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

Similar topics

1
by: Hubert Wong | last post by:
Hi, I am writing some C# code that moves files from a source folder to a target folder on the same machine. However, if the target folder is a shared folder, using the File.MoveTo method alone...
1
by: Ole Hanson | last post by:
I would like to be able to generate documentation for a custom configuration file (xml) to enable future support engineers to understand applicable values to the various elements inside the...
2
by: Rob G | last post by:
Hi, I am new to this ASP.NET thing and while going very slow, I am learning. Then I got a Configuration Error out of nowhere when I ran my project. I do have Excel as reference (but I haven't...
1
by: Oney | last post by:
I use Microsoft Exception management block to publish exception to event log. but some error occured. Error is blow, how can I solve this problem ??? Configuration Error Description: An error...
1
by: Sean | last post by:
Open a new blank VB ASP.NET Project. Build Start with Debugging. Result: Configuration Error Description: An error occurred during the processing of a configuration file required to service...
4
by: Terry Holland | last post by:
I'm getting an intermittant error on my development machine when I run my ASP.Net app. If I reboot then things are fine for a couple of times then error appears again. If I use a diff development...
5
by: Ivan Weiss | last post by:
Hey all, I am trying to add a configuration file to my app so that I can store configuration options and provide a form to allow the user to change them. I know that these used to always be in...
1
by: mcstrini | last post by:
I'm trying to have my application use a special config file which is shared across servers, and want to include a custom section (for URLs of report services associated with database instances). ...
4
by: Fred | last post by:
I have a number of files that I need to zip up and upload to a web site. Can anyone tell me how to create a .zip file and add files to the .zip file. You can assume that the PC on which this...
1
by: John | last post by:
Hi I am looking for an editor that will allow a user to edit application configuration easily and I have found below; http://www.codeproject.com/KB/cs/configeditor.aspx Unfortunately it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
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,...
0
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...

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.