Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

machine.config

Posted on 2010-11-15
2
Medium Priority
?
669 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 1500 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

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

886 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