15.02.2015 Views

C# 4 and .NET 4

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

452 ❘ ChaPTer 18 Assemblies<br />

Installing .<strong>NET</strong> 4 also installs the Native Runtime Optimization Service. This service can be used to defer<br />

compilation of native images <strong>and</strong> regenerates native images that have been invalidated.<br />

The comm<strong>and</strong> ngen install myassembly /queue can be used by an installation program to defer<br />

compilation of myassembly to a native image using the Native Image Service. ngen update /queue<br />

regenerates all native images that have been invalidated. With the ngen queue options pause , continue ,<br />

<strong>and</strong> status you can control the service <strong>and</strong> get status information.<br />

You might ask why the native images cannot be created on the developer system,<br />

<strong>and</strong> you just distribute the native image to the production system. The reason is that<br />

the native image generator takes care of the CPU that is installed with the target<br />

system <strong>and</strong> compiles the code optimized for the CPU type. During installation of the<br />

application, the CPU is known.<br />

Configuring .neT aPPliCaTions<br />

COM components are used in the registry to confi gure components. Confi guration of .<strong>NET</strong> applications<br />

is done by using confi guration fi les. With registry confi gurations, an xcopy deployment is not possible.<br />

Confi guration fi les can simply be copied. The confi guration fi les use XML syntax to specify startup <strong>and</strong><br />

runtime settings for applications.<br />

This section explores the following:<br />

➤<br />

➤<br />

➤<br />

What you can confi gure using the XML base confi guration fi les<br />

How you can redirect a strongly named referenced assembly to a different version<br />

How you can specify the directory of assemblies to fi nd private assemblies in subdirectories <strong>and</strong><br />

shared assemblies in common directories or on a server<br />

Configuration Categories<br />

The confi guration can be grouped into these categories:<br />

➤<br />

➤<br />

➤<br />

➤<br />

Startup settings enable you to specify the version of the required runtime. It ’ s possible that different<br />

versions of the runtime could be installed on the same system. The version of the runtime can be<br />

specifi ed with the < startup > element.<br />

Runtime settings enable you to specify how garbage collection is performed by the runtime <strong>and</strong> how<br />

the binding to assemblies works. You can also specify the version policy <strong>and</strong> the code base with these<br />

settings. You take a more detailed look into the runtime settings later in this chapter.<br />

WCF settings are used to confi gure applications using WCF. You deal with these confi gurations in<br />

Chapter 43, “ Windows Communication Foundation. ”<br />

Security settings are introduced in Chapter 21 <strong>and</strong> confi guration for cryptography <strong>and</strong> permissions is<br />

done there.<br />

These settings can be provided in three types of confi guration fi les:<br />

➤<br />

➤<br />

Application confi guration fi les include specifi c settings for an application, such as binding information<br />

to assemblies, confi guration for remote objects, <strong>and</strong> so on. Such a confi guration fi le is placed into the<br />

same directory as the executable; it has the same name as the executable with a .config extension<br />

appended. ASP.<strong>NET</strong> confi guration fi les are named web.config .<br />

Machine confi guration fi les are used for system - wide confi gurations. You can also specify assembly<br />

binding <strong>and</strong> remoting confi gurations here. During a binding process, the machine confi guration fi le is<br />

consulted before the application confi guration fi le. The application confi guration can override settings<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!