Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

machine.config

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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

688 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