?
Solved

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

Posted on 2008-10-10
3
Medium Priority
?
5,102 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Accepted Solution

by:
novynov earned 1000 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

752 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