473,403 Members | 2,071 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,403 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 1777
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...
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: 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?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.