1 / 17

Importing outside DLLs into .Net platform and using them

Importing outside DLLs into .Net platform and using them. By Anupama Atmakur. Overview. What is a DLL ? Issues in using DLL :DLL hell. Subtle difference between a DLL and a dot net assembly What is an assembly? How to create a DLL? How is a DLL imported into .net?

kaya
Télécharger la présentation

Importing outside DLLs into .Net platform and using them

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. Importing outside DLLs into .Net platform and using them By Anupama Atmakur

  2. Overview • What is a DLL ? • Issues in using DLL :DLL hell. • Subtle difference between a DLL and a dot net assembly • What is an assembly? • How to create a DLL? • How is a DLL imported into .net? • Demo showing how to import a DLL into .net?

  3. What is a DLL? • “DLL” stands for dynamic-link library. • It is an executable file that acts as a shared library of functions. • The executable code for the functions are located in a DLL, which are compiled, linked, and stored separately from the processes that use them.

  4. What makes it dynamic? • DLL is a file that is loaded, and its functions linked dynamically at run time. • It allows an executable module to include only the information needed to locate the executable code for a DLL. • Where as in static linking, the linker gets all of the referenced functions from the static link library and places it with in your code into your executable.

  5. Advantages… • Save memory and disk space. • Upgrade easier. • Provide after-market support. • Provide a mechanism to extend the MFC library classes. • Support Multilanguage programs

  6. DLL Hell problem using DLLs… When a DLL is updated on a computer, the older version is removed and replaced with the newer version. If the new version is not compatible with the previous version, this usually crashes applications that use the component.

  7. Solution… The .NET Framework provides support for side-by-side execution, which allows multiple versions of an assembly to be installed on the same computer, at the same time. As a result managed applications can select which version to use without affecting other applications that use a different version.

  8. Shift from DLL to Dot Net Assemblies in Microsoft. NET • DLL contains library code to be used by any program running on Windows. • Dot net assemblies are understandable to only Microsoft. NET and can be used only in .NET managed applications. • Assemblies can maintain versioning with the help of the manifest. • Giving a Strong name to an assembly is a key to avoid DLL Hell.

  9. What is an assembly? • Assemblies are the building blocks of .NET Framework applications. • They contain the definition of types, versioning information for the type, meta-data, and manifest. • They form the fundamental unit of deployment, version control, reuse and security permissions.

  10. How to create a DLL? • A DLL can be created using the following command line statements: • Single-File: csc /out:add.dll /target:library add.cs • Multi-File: • csc /out:samlemodule.netmodule /target:module add.cs • al /out:MultiFileAssembly.dll /target:library samlemodule.netmodule

  11. Using a DLL… • Using command line statement csc /target:library /reference:add.dllprogram.cs • Using GUI

  12. Strong Name • Shared assemblies must have a strong name as it is a unique identifier of an assembly. • A strong name consists of the assembly's name, version and culture metadata, plus a cryptographic public key and a digital signature. • Public key is used for validation. • sn -k Keyfile.snk • This command creates a new pair of keys and stores it in a filenamed Keyfile.snk.

  13. Creating an Assembly Strong Name The following attribute are added to the AssemblyInfo.cs using System.Reflection; using System.Runtime.CompilerServices; [assembly: AssemblyCulture(“en-us")] [assembly: AssemblyVersion(“1.0.0.0")] [assembly: AssemblyKeyFile(" Keyfile.snk")]

  14. Sharing an Assembly: The Global Assembly Cache • Install an assembly in the GAC gacutil /i mult.dll • Remove the assembly from the GAC gacutil /u math

  15. Demo to secure a dll using a keyfile.

  16. References • http://msdn2.microsoft.com/en-US/library/3707x96z(VS.80).aspx • http://support.microsoft.com/kb/815065 • http://www.codeproject.com/dll/The_DLL_Hell.asp

  17. Questions??

More Related