15.02.2015 Views

C# 4 and .NET 4

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

458 ❘ ChaPTer 18 Assemblies<br />

overriding Publisher Policies<br />

With a publisher policy, the publisher of the shared assembly guarantees that a new version of the assembly<br />

is compatible with the old version. As you know, from changes of traditional DLLs, such guarantees don’t<br />

always hold. Maybe all except one application is working with the new shared assembly. To fix the one<br />

application that has a problem with the new release, the publisher policy can be overridden by using<br />

an application configuration file.<br />

You can disable the publisher policy by adding the XML element with the attribute<br />

apply=“no”.<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

code snippet Client/App.config<br />

By disabling the publisher policy, you can configure different version redirection in the application<br />

configuration file.<br />

runtime Version<br />

Installing <strong>and</strong> using multiple versions is not only possible with assemblies but also with the .<strong>NET</strong> runtime<br />

(CLR). The versions 1.0, 1.1, 2.0, <strong>and</strong> 4.0 (<strong>and</strong> later versions) of the CLR can be installed on the same<br />

operating system side by side. Visual Studio 2010 targets applications running on CLR 2.0 with .<strong>NET</strong> 2.0,<br />

3.0, <strong>and</strong> 3.5 <strong>and</strong> CLR 4.0 with .<strong>NET</strong> 4.<br />

If the application is built with CLR 2.0, it might run without changes on a system where only CLR version<br />

4.0 is installed. The reverse is not true, if the application is built with CLR 4.0, it cannot run on a system<br />

where only CLR 2.0 is installed.<br />

In an application configuration file, it’s not just possible to redirect versions of referenced assemblies; you<br />

can also define the required version of the runtime. You can specify the version that’s required for the<br />

application in an application configuration file. The element marks the runtime<br />

versions that are supported by the application. The order of elements defines<br />

the preference if multiple runtime versions are available on the system. The configuration here prefers the<br />

.<strong>NET</strong> 4 runtime <strong>and</strong> also supports 2.0. Remember, for this to be possible, the application must be built<br />

with the target framework .<strong>NET</strong> 2.0, 3.0 or 3.5.<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

summary<br />

Assemblies are the new installation unit for the .<strong>NET</strong> platform. Microsoft learned from problems with<br />

previous architectures <strong>and</strong> did a complete redesign to avoid the old problems. This chapter discussed the<br />

features of assemblies: they are self-describing, <strong>and</strong> no type library <strong>and</strong> registry information is needed.<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!