Solved

machine.config

Posted on 2010-11-15
2
645 Views
Last Modified: 2012-08-13
I understand that I will have multiple machine.config files on a machine, 1 per framework version.  This brings me to a few questions.

1) Is there a single config file somewhere that I can put common entries in?  Specifically I am looking at a readonly connection string for a database that virtually every application we have needs.  We have console apps, windows services, and web applications in 1.1, 2.0, 3.5, and 4.0.

2) If I have a .NET 2.0 DLL called from a .NET 4.0 web application, which machine.config will the .NET 2.0 DLL be reading from?

3) How does 64-bit frameworks work into this?  If I have a 64-bit 4.0 app calling a 32-bit 2.0 DLL, which config file would the 32-bit 2.0 DLL read from?

Rhetorical: Why couldn't they just name them framework.config and then have 1 common machine.config?

Thanks.
0
Comment
Question by:SkipFire
2 Comments
 
LVL 10

Accepted Solution

by:
wls3 earned 500 total points
ID: 34141974
Q 1:

I will assume IIS 7 for argument's sake.  The current structure of IIS 7 .config files is as follows:

machine | root web.config | site web.config | application web.config | directory web.config

Also, note that the IIS applicationHost.config file is parsed by the framework in considerations for the site web.config.  For your purposes, try adding entries to the root web.config (%systemroot%\system32\inetsrv\config) file.  To keep it clean, you can create a secondary file in the same directory and use the ApplicationManager class to access data within this file.  Check out the sample code in the link below for examples of how to access different configuration sets (application, machine, etc):

http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.aspx

Note, this class was introduced with .NET 2.0, so, older apps (1.0/1.1) will be unable to utilize it.

Q 2:

The fully qualified assembly name is listed in one of the .config files.  It will automatically point to the appropriate run time, regardless of the version of the targeted application.  In short, a .NET 2.0 dll will read the 2.0 .config files.

Q 3:

You have to recompile 32-bit assemblies as 64-bit.  Here is a link for reference:

http://msdn.microsoft.com/en-us/library/ms973190.aspx

Since 32-bit assemblies use 4-byte pointers and 64-bit use 8-byte they are fundamentally incompatible.  If you were running a 32-bit app on a 64-bit machine, that is, however, doable.

http://msdn.microsoft.com/en-us/library/ms241064.aspx
http://blogs.microsoft.co.il/blogs/dhelper/archive/2009/01/22/how-to-run-as-32bit-executable-on-a-64bit-machine.aspx
0
 
LVL 4

Author Closing Comment

by:SkipFire
ID: 34243025
After taking the time and setting up all the tests I found that the only thing that seems to matter is the version of the origination object, after that everything uses that config file.  So if you run a web application that is a 64-bit 4.0 DLL, my observations show that the .NET 64-bit 4.0 machine.config is read by all downstream DLLs.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
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 …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
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…

813 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

11 Experts available now in Live!

Get 1:1 Help Now