Solved

machine.config

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

13 Experts available now in Live!

Get 1:1 Help Now