An Overview of Assemblies: .NET Programs

Environment: .NET

If and when you start working with .NET, you will find that the applications you create are not quite the same as the ones you created previously. While you can still create a file with a DLL or EXE, the resulting files are not the same as previous DLLs and EXEs. In simple terms, any application you create -- be it a forms application, class library, a service, or something else - will be built into an assembly.

When you compile a program in .NET, the result is a file called an assembly. An assembly is a collection of the resources that your application uses along with the types. These assemblies will contain information specific to your program along with a lot of additional information that the .NET Framework will be able to use. The information in the assembly will be used for a variety of purposes including type identification, versioning, deploying, referencing scope, and security.

An assembly, which you can think of as your program, also contains a manifest. This manifest is a set of metadata that contains information about the assembly itself. This information includes:

  • The name of the assembly
  • The version of the assembly (so it can tell this assembly from future versions)
  • A list of files in the assembly
  • Information an any exported types in the assembly
  • Information on any other assemblies referenced by this one

A manifest may also contain other information such as the culture or language the assembly supports as well as a public key if there is a need for strong names to be assigned to the assembly.

An assembly will also have a set of values that can be accessed and/or set. For example, you can store copyright information within your assembly by setting the value of an attribute called AssemblyCopyright. You can set this attribute within the source code of your program. Using a concept called reflection, you can determine and use this value in your executing program. There are a number of preset attributes you can use. These include AssemblyCompany, AssemblyCopyright, AsemblyCulture, AssemblyDelaySign, AsemblyDescription, AssemblyFileVersion, AssemblyInformationalVersion, AssemblyKeyFile, AssemblyKeyName, AssebmlyProduct, AssemblyTitle, AssemblyTradmark, and AssemblyVersion.

If these attributes don't fit your needs, you can also create your own attributes. For example, you can create an attribute that indicates if the assembly is a final version or a testing version. You could also create attributes to indicate the programmer responsible for the program. You could also use attributes to extend the current programming language you are using. The use of attributes is limitless.

For more on attributes, check out the Attributes category of the CodeGuru C# Basic Syntax section (http://www.codeguru.com/cs_syntax/index.shtml).

In Summary...

The programs you create in .NET are called assemblies. The assembly manifests is a list of the contents of the assembly. You can add your own values to an assembly by using attributes. With reflection -- not covered here -- you can then access those values from your own programs.



About the Author

Bradley Jones

Bradley Jones, in addition to managing CodeGuru, Brad! oversees the Developer.com Newtwork of sites including Codeguru, Developer.com, DevX, VBForums, and over a dozen more with a focus on software development and database technologies. His experience includes development in C, C++, VB, some Java, C#, ASP, COBOL, and more as well as having been a developer, consultant, analyst, lead, and much more. His recent books include Teach Yourself the C# Language in 21 Days, Web 2.0 Heroes, and Windows Live Essentials and Services.
Google+ Profile | Linked-In Profile | Facebook Page

Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • Due to internal controls and regulations, the amount of long term archival data is increasing every year. Since magnetic tape does not need to be periodically operated or connected to a power source, there will be no data loss because of performance degradation due to the drive actuator. Read this white paper to learn about a series of tests that determined magnetic tape is a reliable long-term storage solution for up to 30 years.

Most Popular Programming Stories

More for Developers

RSS Feeds