Solved

How to access app.config file in class library type project?

Posted on 2008-10-10
3
5,095 Views
Last Modified: 2013-11-08
I have created Add-In project for outlook in .Net 3.5 using Shared Add In project.
This project downloads attachments from selected mail in outlook and save it in our database.

I want to store connection string for Sql Server and physical path to the folder where I want to download all attachments.

I want to put this information in App.config file so user can change it according to his/her requirement and configuration.

I tried to add this information in app.config file but I can not fetch stored information.

I think that app.config file not working because my project is class library type.

How can I use app.config file or is there any other alternate to getting same job?
0
Comment
Question by:aplusexpert
3 Comments
 
LVL 4

Accepted Solution

by:
novynov earned 250 total points
ID: 22706728
I believer there are a couple of ways you can do this:

- Store the info in the app.config of the loading/calling application (Outlook?). Remember, the app.config file needs to be named as <ExeName>.exe.config for it to get loaded. Also, as far as I know, it will only get loaded if the calling application is a "native" .NET application (i.e. not doing interop) - though I haven't tested it.

- Manually load the configuration file somewhere in your add-in using the APIs from the System.Configuration namespace - and then read its settings. Here's a link to some code for doing this in a variety of ways (e.g. loading arbitrary files, loading the dll specific config) - http://www.bearcanyon.com/dotnet/#AssemblySettings. I haven't looked at / used this code, so I can't vouch for its goodness.

Here's an article I just found that deals with some configuration issues - http://chriswoodill.blogspot.com/2007/08/managing-configuration-files-and-net.html

According to the author, if you have both an app.config for your exe as your dll, only the exe one will get loaded, not the dll one.

I hope this helps. At this point, I haven't dug into this deeper as my normal approach for dll settings is to store them in the exe / website app.config / web.config.

Let me know if I can be more help.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now