1 / 14

Working with assemblies

Working with assemblies. Compiling a C# program : console program : use the csc.exe (C Sharp Compiler) to generate an .exe file not a "true" exe, needs the .NET CLR virtual machine in order to be translated from MSIL to binary (machine language) this .exe is called an assembly. .DLL files.

wwolf
Download Presentation

Working with assemblies

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Working with assemblies Compiling a C# program : console program : use the csc.exe (C Sharp Compiler) to generate an .exe file not a "true" exe, needs the .NET CLR virtual machine in order to be translated from MSIL to binary (machine language) this .exe is called an assembly

  2. .DLL files usage : suppose you wrote a test.cs file containing one or more classes use the VS cmd.exe tool (that good old ugly DOS interface) generates test.exe csc test.cs

  3. .DLL files in order to generate a .DLL file : in order to generate a .netmodule file csc /t:library test.cs csc /t:module test.cs use .netmodule files to create assemblies containing files from different .NET languages

  4. DLL versioning "the .DLL Hell" : updating a .DLL file might corrupt existing applications several versions of a .DLL can now exist Assembly manifest : meta data about the assembly : just copy/paste an assembly to an appplication bin directory.

  5. Assembly signing code security and management : sharing assemblies : copy the .ddl file to the current project directory add a project reference to the current project problem with .dll updates (versioning)

  6. Assembly signing highly shared assemblies (C# standard Class Library) use another system : located in the GAC (Global Assembly Cache) C:\WINNT\assembly directory security issues !

  7. Assembly signing an assembly to be installed in the GAC must have a strong name (encryption by public/private keys, RSA Algorithm) how to sign an assembly : produce a public/private key pair sign the assembly register the assembly to the GAC

  8. producing a key pair .NET utility tools (access by the dedicated command prompt) sn.exe (strong name) sn –k filename.snk generates a binary file

  9. signing an assembly al.exe (assembly linker) uses a module (.net module file) al /out:filename.dll module /keyfile:keyfilename al /out:toto.dll class1.netmodule /keyfile:titi.snk generates the strong named toto.dll assembly

  10. registering to the GAC gacutil.exe (assembly linker) use the /i command to install the assembly gacutil /i assembly.dll

  11. using the assembly info file strong name signing is possible via the assembly info file attributes : in a VS Project : AssemblyInfo.cs file attributes : [assembly: AssemblyTitle("….")] [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyDelaySign(false)] [assembly: AssemblyKeyFile(keyfilename)]

  12. using the assembly info file application directory .cs source files .snk key file obj bin Debug .dll output Release

  13. using the assembly info file if a mykeys.snk file is use to give a string name : the following [assembly:AssemblyKeyFile("..\\..\\mykeys.snk")] attribute is written in the AssemblyInfo.cs file the assembly has still to be installed in the GAC with gacutil.exe

  14. Deploying a C# application

More Related