Create public assembly

Rajni.Shekhar
Posted by Rajni.Shekhar under C# category on | Points: 40 | Views : 4098
Steps to create a public assembly

1) Create a new project of class library.
2) Write your methods in a class.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MathClass
{
public class SampleClass
{
public int Add(int a, int b)
{
try
{
return a + b;
}
catch (Exception objEx)
{
throw objEx;
}
}
public int Subtraction(int a, int b)
{
try{
return a-b;
}
catch (Exception objEx)
{
throw objEx;
}
}

}
}

3) Build class library
4) create strong key pair using following line

c:\sn.exe -k myKey.snk

5) Sign assembly by browsing your created key pair.

Right click on your project->Properties->Signing->sign the assembly

6) Rebuild your class library
7) Install assembly using gacutil:


Open Visual Stuadio Command Prompt
gacutil -i "<dllname with path>"


Public assembly created.

Now you can use assembly by add reference in your project.

Comments or Responses

Posted by: Raj_Chennai on: 3/28/2012 Level:Starter | Status: [Member] | Points: 10
hi Rajni Shekhar,
can you say how to perform assembly creation operation in visual studio command prompt using gacutil.Pls provide example

Posted by: Rajni.Shekhar on: 3/28/2012 Level:Bronze | Status: [Member] | Points: 10
Hi Raj_Chennai,
i am not getting your point.
Even i have given example to install assembly by using gacutil command:

C:\gacutil -i "<dllname with path>"

Login to post response