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

  • Hybrid cloud platforms need to think in terms of sweet spots when it comes to application platform interface (API) integration. Cloud Velocity has taken a unique approach to tight integration with the API sweet spot; enough to support the agility of physical and virtual apps, including multi-tier environments and databases, while reducing capital and operating costs. Read this case study to learn how a global-level Fortune 1000 company was able to deploy an entire 6+ TB Oracle eCommerce stack in Amazon Web …

  • With 81% of employees using their phones at work, companies have stopped asking: "Is corporate data leaking from personal devices?" and started asking: "How do we effectively prevent corporate data from leaking from personal devices?" The answer has not been simple. ZixOne raises the bar on BYOD security by not allowing email data to reside on the device. In addition, Zix allows employees to maintain complete control of their personal device, therefore satisfying privacy demands of valued employees and the …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds