Solved

machine.config

Posted on 2010-11-15
2
652 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
[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
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

Stressed Out?

Watch some penguins on the livecam!

Question has a verified solution.

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

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 …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

632 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