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

  • Protecting business operations means shifting the priorities around availability from disaster recovery to business continuity. Enterprises are shifting their focus from recovery from a disaster to preventing the disaster in the first place. With this change in mindset, disaster recovery is no longer the first line of defense; the organizations with a smarter business continuity practice are less impacted when disasters strike. This SmartSelect will provide insight to help guide your enterprise toward better …

  • Java developers know that testing code changes can be a huge pain, and waiting for an application to redeploy after a code fix can take an eternity. Wouldn't it be great if you could see your code changes immediately, fine-tune, debug, explore and deploy code without waiting for ages? In this white paper, find out how that's possible with a Java plugin that drastically changes the way you develop, test and run Java applications. Discover the advantages of this plugin, and the changes you can expect to see …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds