Configured Assemblies - get and set

J

JH

(I posted this on framework.setup group but got no reply. So I'm posting
it in this group again. Please let me know if this is not the right forum to
post this
question. Thanks)

So we'd like to copy the "Configured Assemblies" settings and deploy the
same list (configure the assemblies the same way) on other machines.
Is there a Windows or .NET API to get and set this information?

We tried to read the info from this file:
"%windir%\Microsoft.NET\Framework\v#.#.####\CONFIG\machine.config"

There are two issues:
1. it's probably not the documented/supported way for this purpose
2. it doesn't always work on 64bit machines. On 64bit machines, the file
is sometimes in Framework, sometimes in Framework64. Usually two
copies of the machine.config file exist. Sometimes one is modified
(when configured assemblies changes are done in mscorecfg) some
times the other file is modified. We haven't figured out when to
use which file.
 
Z

Zhi-Xin Ye [MSFT]

Dear JH,

As I understand, you add some assembly configuration information into
machine.config file, and want to copy these configuration information to
other machines.

The assembly configuration information are store in the "assemblyBinding"
section under the "runtime" section. We can use
ConfigurationManager.OpenMachineConfiguration() method to open the machine
configuration file on the current machine, and read or write configuration
information with the Configuration object.

For example, we can do something like this:

========Sample Code===================

Configuration MachineConfig =
ConfigurationManager.OpenMachineConfiguration();

//The "Configured Assemblies" information are stored in the
runtime section
ConfigurationSection runtimeSection =
MachineConfig.Sections["runtime"]; //case sensitive
string content = runtimeSection.SectionInformation.GetRawXml();
Console.WriteLine(content);

//do something with the configuration section

runtimeSection.SectionInformation.SetRawXml(content);
MachineConfig.Save();

======================================

For more information about this, you can refer to:

ConfigurationManager.OpenMachineConfiguration() method
http://msdn.microsoft.com/en-us/library/system.configuration.configurationma
nager.openmachineconfiguration.aspx

However, for redirecting assembly versions on target machines, I would
recommend you create a publisher policy file instead of changing the
machine.config file programmatically.

For how to create a publisher policy file, you can refer to this document:

How to: Create a Publisher Policy
http://msdn.microsoft.com/en-us/library/dz32563a.aspx

If you are unclear about any of this, please feel free to let me know.

Have a nice day!

Sincerely,
Zhi-Xin Ye
Microsoft Managed Newsgroup Support Team

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

JH

Thanks Zhi-Xin, for the reply.

On a 64bit machine, is it supposed to give me different
settings for the 32 version and the 64 version of machine.config?
What I mean is that there is a machine.config under Framework
directory, another machine.config under Framework64 directory.
 
Z

Zhi-Xin Ye [MSFT]

Dear JH,

On a 64-bit machine, the Framework directory contains the assemblies that
are specific to the WoW64(32-bit emulation on 64-bit platforms), while the
Framework64 directory contains assemblies that are specific to the 64bit
platform. Assemblies which are platform agnostic are available in either or
both the directories.

Which machine.config file that the
ConfigurationManager.OpenMachineConfiguration() method opens is based on
the target platform of your application.

If the target platform property of your application is set to "Any
CPU"(this is by default) or "x64", when running on a 64-bit machine, the
ConfigurationManager.OpenMachineConfiguration() method will open the
machine.config file under the Framework64 directory.

If the target platform property of your application is set to "x86", when
running on a 64-bit machine, the
ConfigurationManager.OpenMachineConfiguration() method will open the
machine.config file under the Framework directory.

So you can create two application, one specific to x86 target platform, the
other specific to "Any CPU"(or x64) target platform, then you should be
able to access both machine.config files.

Sincerely,
Zhi-Xin Ye
Microsoft Managed Newsgroup Support Team

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Z

Zhi-Xin Ye [MSFT]

Dear JH,

Does my last reply make sense to you? If you need further help, please feel
free to let me know, I will be happy to be of assistance.

Have a nice day!

Sincerely,
Zhi-Xin Ye
Microsoft Managed Newsgroup Support Team

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

JH

Sorry for the late reply. We got carried away by some other issues.
We'll be testing this in the next few days and report back.
 
Z

Zhi-Xin Ye [MSFT]

Dear JH,

Thanks for your feedback, I'm looking forward to hearing from you.

Have a nice day!

Sincerely,
Zhi-Xin Ye
Microsoft Managed Newsgroup Support Team

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Z

Zhi-Xin Ye [MSFT]

Dear JH,

I'm glad that my suggestion helped.

Have a nice day!

Sincerely,
Zhi-Xin Ye
Microsoft Managed Newsgroup Support Team

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top