Solved

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

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

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

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…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

691 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