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

  • Not long ago, security was viewed as one of the biggest obstacles to widespread adoption of cloud-based deployments for enterprise software solutions. However, the combination of advancing technology and an increasing variety of threats that companies must guard against is rapidly turning the tide. Cloud vendors typically offer a much higher level of data center and virtual system security than most organizations can or will build out on their own. Read this white paper to learn the five ways that cloud …

  • The explosion in mobile devices and applications has generated a great deal of interest in APIs. Today's businesses are under increased pressure to make it easy to build apps, supply tools to help developers work more quickly, and deploy operational analytics so they can track users, developers, application performance, and more. Apigee Edge provides comprehensive API delivery tools and both operational and business-level analytics in an integrated platform. It is available as on-premise software or through …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds