Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Config Location + 500 pts

Posted on 2006-04-07
4
Medium Priority
?
185 Views
Last Modified: 2010-04-23
If I have an application which references several dlls and they are located in the same folder, then it is possible to read settings from the config file, does it automatically look in the main folder for a config file?


The reason I ask is that I am also making provision for a web service which also references the dlls, do I just need to copy the config file to the web service directory?
0
Comment
Question by:rocky050371
  • 2
3 Comments
 
LVL 6

Expert Comment

by:Jayadev Nair
ID: 16400591
Hope you are using .NET 2.0.
The configuration files are expected to be in the runpath where assemblies built. The default application config file, yourApp.exe.config is generated by VS 2005 when you build the project based on the app.config. If aop.config is not there in your project, just add the file. After Building, you will get ApplicationName.exe.config @ runpath

To copy a file in project to a specific folder while building you can use custom build events like you write on a batch file (e.g. xcopy .... ....)
0
 

Author Comment

by:rocky050371
ID: 16400621
The point I am trying to raise, is, the dll automatically pick up the main application config, would this be the same if the dll was in the web service directroy, if I dropped the application config in there
0
 
LVL 6

Accepted Solution

by:
Jayadev Nair earned 1500 total points
ID: 16406484
Yes, you can. but keep in mind the below matters

Say you have a windows solution with two or more dlls and an executable project.
That case even you have each config for each dlls, no meaning. Because the application reads from the application config, which will be the app.config ofthe windows executable project since the whole app runs on the thread started by windowsapplication. Consider the same case in web app too. So a config file will looks like

<configuration>
      <configSections>
            <sectionGroup name="userSettings" type="" >
                  <section name="DLL1.Settings" type="" allowExeDefinition="" requirePermission="" />
                  <section name="DLL2.Settings" type="" allowExeDefinition="" requirePermission="" />
            </sectionGroup>
      </configSections>

      <userSettings>
      <DLL1.Settings>
            <setting name="MyConfig" serializeAs="String">
                <value>val1</value>
            </setting>
      </DLL1.Settings>
      <DLL2.Settings>
            <setting name="MyConfig" serializeAs="String">
                  <value>val2</value>
            </setting>
      </DLL2.Settings>
</userSettings>
</configuration>

In above scenario, DLL1.settings will be the config for DLL1 you have and DLL2 will be the config which DLL2 belongs to. So keep all appliaction configuration on your app.config. At runtime you can read those.

Thanks!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Loops Section Overview
Suggested Courses

810 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