Introduction
This blog explains some steps and methods
to create an assembly using c# in Visual Studio. There are two methods
available in .net framework for creating assembly one is Visual Studio
Command Prompt and other is Integrated Development Environment (IDE). Lets
discuses about these methods
Visual Studio Command Prompt: You can create
an assembly at the command prompt by using command-line compilers. To do
this, type the code at the command prompt. To create an assembly with the
.exe extension at command prompt, use the following syntax:
Compiler command module name
In this syntax, compiler command is the
command for the language used in your code module, and module name is the
name of the code module that you want to compile into the assembly.
For example, if you want to compile a code
module called myCode into a assembly you can type the following command:
In Visual Basic
Vbc myCode.vb
In C#
Csc myCode.cs
Integrated Development Environment (IDE): You
can also create assemblies by using the IDE such as Visual Studio .NET
2005. After creating a project in the IDE, you can use the Build command on
the toolbar to create an assembly. You must select the appropriate
programming language, Visual Basic or C# while creating a new project to
wnsure that the correct that the correct syntax options are used while
creating the assembly.
Steps to Create Assemblies
The following are the steps to create
single-file and multifile assemblies in C#.
Create a source code file containing the
following code example:
Public static void Main(string[] args)
{
Console .WriteLine("Welcome to C# world");
Console.ReadLine() ;
}
}
Class Greeting
{Public static void Main(string[] args)
{
Console .WriteLine("Welcome to C# world");
Console.ReadLine() ;
}
}
Save the source code file with the .cs
extension. For example, for the above code example, save the file as
Greeting.cs
Execute the csc assemblyname.cs command. This
generates file called assemblyname.exe. for example,for the above code
execute the following command from the command prompt:
Ese Greeting.cs
Join the conversation! Your thoughts help the community grow.