Demo On Shared Assemblies: Class Library Project: Console Application Project
This document provides instructions for creating a shared assembly library and consuming it from another application:
1. A class library project is created to contain shared methods.
2. A strong name key is generated for the assembly.
3. The assembly is built as a DLL and deployed to the GAC.
4. A console application is created that references the shared assembly and calls one of its methods.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
72 views4 pages
Demo On Shared Assemblies: Class Library Project: Console Application Project
This document provides instructions for creating a shared assembly library and consuming it from another application:
1. A class library project is created to contain shared methods.
2. A strong name key is generated for the assembly.
3. The assembly is built as a DLL and deployed to the GAC.
4. A console application is created that references the shared assembly and calls one of its methods.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4
Demo on Shared Assemblies
1. Create a Class Library Project.
Open Visual Studio 2008. Click on File New Project. Select te lan!ua!e as Visual C" and project te#plate as Class $i%rar&. 'nter te na#e as SharedAssemblyLibrary. Click on O(. )t creates a new class li%rar& project. )nitiall& it contains a new class called class*. )n te solution e+plorer, rena#e te class*.cs as MySharedMethods.cs. -en t&pe te .ollowin! code. 2. Create a strong name key. .N'- /.0 and Visual Studio 20*0 0our 12 3 Pa!e * o. / Alication !"# Demo on Shared Assemblies )n tis e+a#ple, Class $i%rar& Project4 SharedAssemblyLibrary Console 5pplication Project4 SharedAssemblyDemo usin! S&ste#6 usin! S&ste#.Collections.7eneric6 usin! S&ste#.$in86 usin! S&ste#.-e+t6 na#espace Sared5sse#%l&$i%rar& 9 pu%lic class :&Sared:etods 9 pu%lic int 7etSi#ple)nterest;int p, int n, int r< 9 int si = p > n > r ? *006 return ;si<6 @ @ @ Ai!t click on te project in te Solution '+plorer and coose Properties. )n te project properties, select te ceck %o+ Si!n te asse#%l&. )n te Coose a stron! na#e ke& Ble drop down, select CNewD option. )n te Create stron! na#e ke& dialo! %o+, enter te na#e o. te stron! na#e ke& Ble as My$ey%ile. Enceck te Protect #& ke& Ble wit a password ceck%o+. Click on O(. ". C&stomi'e the Assembly (n)ormation *Assembly(n)o.cs+. Can!e te asse#%l& Fersion as 1.2.,.,. -. .enerate the DLL %ile. Guild te class li%rar& project %& clickin! on Guild #enu Guild Solution. !. /rite the assembly into .AC *.lobal Assembly Cache+. Open te .ollowin! .older. C#0/indo1s0Assembly Hra! and drop te SharedAssemblyLibrary.DLL Ble .ro# %inIHe%u! .older into te c4IwindowsIasse#%l& .older. 2. (n3oke the Shared Assembly. Create a new Console 5pplication. Na#e4 SharedAssemblyDemo Click on Project 5dd Ae.erence. Click on Growse ta%. .N'- /.0 and Visual Studio 20*0 0our 12 3 Pa!e 2 o. / Fro# te class li%rar& projectJs %inIHe%u! .older, select te SharedAssemblyLibrary.dll Ble and click on O(. -en te .dll Ble re.erence will %e added. 'nter te code as .ollows4 .N'- /.0 and Visual Studio 20*0 0our 12 3 Pa!e 1 o. / usin! S&ste#6 usin! S&ste#.Collections.7eneric6 usin! S&ste#.$in86 usin! S&ste#.-e+t6 usin! Sared5sse#%l&$i%rar&6 na#espace Sared5sse#%l&He#o 9 class Pro!ra# 9 static Foid :ain;strin!KL ar!s< 9 :&Sared:etods #s# = new :&Sared:etods;<6 int p, n, r6 Console.Mrite$ine;N'nter p, n, r Falues4N<6 p = ConFert.-o)nt12;Console.Aead$ine;<<6 n = ConFert.-o)nt12;Console.Aead$ine;<<6 r = ConFert.-o)nt12;Console.Aead$ine;<<6 int si = #s#.7etSi#ple)nterest;p, n, r<6 Console.Mrite$ine;NSi#ple )nterest is4 N O si<6 Console.Aead;<6 @ @ @ 4&t&t# 4&t&t# .N'- /.0 and Visual Studio 20*0 0our 12 3 Pa!e / o. /