473,385 Members | 1,707 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,385 software developers and data experts.

app.config setting for Component object in c#

In normal application the set and get of appSettings are simply as following

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

string log = System.Configuration.ConfigurationSettings.AppSett ings["Log"];

However, the same setting in my C#'s COM object doesn't work at all and keeps on returning "null" value.

Any comment ? Please help
Jul 21 '05 #1
2 1774
What exe is your COM object loaded into (assuming its an in-proc object)
& what is the name of your config file?

..config files are associated with an exe so if your object is loaded into Excel then the framework is looking for excel.exe.config . Which is possibly not a palatable solution.

The built-in config mechansim isn't that useful if you don't control the .exe (technically the appdomain) that your are loaded into.

Niroo

"Maverick" wrote:
In normal application the set and get of appSettings are simply as following

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

string log = System.Configuration.ConfigurationSettings.AppSett ings["Log"];

However, the same setting in my C#'s COM object doesn't work at all and keeps on returning "null" value.

Any comment ? Please help

Jul 21 '05 #2
Correct. .config files are associated with an exe. So if you have a MyComComponent.dll you can't supply just a .config file for it.

The approach that I would go with is to figure out where your code loads using

string path = System.Reflection.Assembly.GetExecutingAssembly(). GetName().CodeBase );

and then manually open a file path + ".config" and use one of the XmlTextReader to read the data out.

The disadvantage is that you do need FileIO permissions, which you don't need for the normal .config file

Niroo

"Maverick" wrote:
That means if i'm creating a pure COM object module using C# (without any main() or exe associated). That's no way i can use a config file to store the configuration data, right ?
"Niroo" wrote:
What exe is your COM object loaded into (assuming its an in-proc object)
& what is the name of your config file?

.config files are associated with an exe so if your object is loaded into Excel then the framework is looking for excel.exe.config . Which is possibly not a palatable solution.

The built-in config mechansim isn't that useful if you don't control the .exe (technically the appdomain) that your are loaded into.

Niroo

"Maverick" wrote:
In normal application the set and get of appSettings are simply as following

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

string log = System.Configuration.ConfigurationSettings.AppSett ings["Log"];

However, the same setting in my C#'s COM object doesn't work at all and keeps on returning "null" value.

Any comment ? Please help

Jul 21 '05 #3

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

Similar topics

2
by: Maverick | last post by:
In normal application the set and get of appSettings are simply as following <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="Log" value="1" /> </appSettings>...
2
by: Maverick | last post by:
In normal application the set and get of appSettings are simply as following <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="Log" value="1" /> </appSettings>...
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...
3
by: manuitpro | last post by:
Hi All, I have been using fsockopen() in a function in a class. I am able to pass all the objects in a class to another page except the fsockopen () value. I have put the values of objects from...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.