Solved

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

Posted on 2008-10-10
3
5,096 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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 tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

895 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