Solved

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

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Latency in .net app using DB in .net 21 66
Receiving a string from a WebService Push 21 51
Search an image for an image 3 31
Regular expression help 2 25
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

831 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