Monday, March 24, 2008

Creating a Private Assembly

In Visual Studio .NET there is always an assembly whether you choose a class library
project or an exe project. Now, let's start some practical work.

  • Start Visual Studio 2005

  • Choose a new C# project [File -> New Project]

  • Choosing new C#:project
  • From template pane choose Class Library Template

  • Set the Location : F:\myWrittings\CSharpBook\Source Codes\

  • Name : privateAssembly

  • Check full code of private
    assembly
    .

  • In Solution explorer change class name from Class1 to mathclass

  • Now right click on mathclass and click on view code

  • Change the name of namespace from privateAssembly to CSharp.AStepAhead.privateAssemby

  • After writing codes of the assembly, now you have to provide some information to
    your assembly as follows:

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; // General Information about an assembly is
controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("privateAssembly")]
[assembly: AssemblyDescription("This is an Example of Book: C#-A Step Ahead
Series")]
[assembly: AssemblyConfiguration("Free I.T. Education Series - A Step Ahead")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("A Step Ahead Series")]
[assembly: AssemblyCopyright("Copyright © A Step Ahead 2007")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("d5389a36-3aa1-4e22-b3df-4cacd5e96531")]

  • For above, you have to click on AssemblyInfo.cs under properties from Solution Explorer
  • The above information tells about the assembly name, title its short description
    and company who had developed it.
  • For more detail check table assembly attributes.
  • Write codes to provide the working for client application.
  • Now build solution from Build -> Build Solution or Ctrl + Shift + B
  • If build succeeded, it means you have created an assembly
  • You can check the assembly using ILDASM

  • No comments:

    Post a Comment