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.

448 ❘ ChaPTer 18 Assemblies<br />

Setting the signing option with Visual Studio adds the /keyfile option to the compiler setting. Visual<br />

Studio also allows you to create a keyfi le that is secured with a password. Such a fi le has the fi le extension<br />

.pfx (see Figure 18 - 11).<br />

figure 18-11<br />

After rebuilding, the public key can be found<br />

inside the manifest. You can verify this using<br />

ildasm , as shown in Figure 18 - 12.<br />

installing the shared assembly<br />

With a public key in the assembly, you can now<br />

install it in the global assembly cache using the<br />

global assembly cache tool gacutil with the /i<br />

option. The /f option forces you to write the<br />

assembly to the GAC, even if it is already there.<br />

gacutil /i SharedDemo.dll /f<br />

Then you can use the Global Assembly Cache<br />

Viewer or gacutil /l SharedDemo to check<br />

the version of the shared assembly <strong>and</strong> see if it is<br />

successfully installed.<br />

figure 18-12<br />

using the shared assembly<br />

To use the shared assembly, create a <strong>C#</strong> console application called Client . Change the name of the<br />

namespace to Wrox.ProCSharp.Assemblies . The shared assembly can be referenced in the same way as a<br />

private assembly: by using the Project → Add Reference menu.<br />

With shared assemblies the reference property Copy Local can be set to false . This<br />

way the assembly is not copied to the directory of the output fi les but will be loaded<br />

from the GAC instead.<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!