banner



How To Register Oracle Dataaccess Dll In Gac

Deploy associates to GAC stride by step

  • By in C#
  • Mar 20th, 2014
  • 42386
  • i

Inroduction

This article covers complete agreement of global assembly cache (GAC),methods/steps to deploy an assembly in GAC, what are Strong name assemblies, steps to give strong proper name to an assembly and finally a sample code instance of Global Assembly Cache using C-sharp code.

What is Global Associates Enshroud (GAC) ?

Global Assembly Cache (GAC) is located on a system and stores assemeblies (DLLs) which is specifically volition be shared by several applications (like web/windows). Common language runtime is installed has a machine code cache chosen the global assembly cache.

In simple words information technology is a identify where we tin can deploy common DLLs in GAC and that common DLLs which can exist further be shared among several/multiple applications on the same computer.

Why we need GAC ?

Let'southward suppose nosotros accept multiple applications on a same figurer (App1 & App2) and both of these applications using the same DLL or associates in their BIN directory. Because both applications are using the aforementioned DLL (i.due east. common DLL) on the aforementioned auto and then we can now movement this common DLL to a common place (global assembly cache - GAC) where both of applications (App1 & App2) can share this common DLL on the same machine.

How to deploy an assembly in GAC

In guild to deploy an assembly in GAC, we have to create a stiff name for an associates.

Kindly Note : We cannot deploy an assembly in GAC without a strong name, Each and every associates need to have a strong name for an assembly in order to deploy it in GAC.

So inorder to deploy or to install an assembly in GAC nosotros need to have strong proper noun for an assembly. And so let'southward understand nearly strong names and how to give strong or how to create stiff name keyfile file.

What are Stiff name assemblies.

Strong name for an associates guarantees the uniqueness past unqiue key pairs. Because an assembly generated with a potent proper noun consist of unique identity with its public fundamental, version number, text proper noun, culture information and a digital signature.

 Information technology guarantees that no one tin generate the same assembly with aforementioned private central and protects an assembly from versioning lineage and tampering. On passing to .Internet framework information technology provides potent integrity bank check or security checks and guarantees that the contents of an assembly have not been inverse since it was built.

Steps to give strong name to an assembly/DLL

Method 1 : Using Visual Studio Command Prompt

 1. Open upwards the visual studio command prompt or .Net control prompt. (You lot can discover command prompt in program files -> Visual studio -> Visual studio tools).

 2.Click to open command prompt and then navigate to projection folder

 eg: to navigate to any drive type drive proper name followed by colon (i.e. to navigate "D" drive type * D: and press on Enter button*). Afterwards navigating to a drive blazon "cd followed past whatever folder proper name" (i.eastward. cd Gacdemo and press on  Enter button).

 Same way you tin can navigate to your own custom folder past using commands.

 3.Get to the project folder using commands in visual studio control prompt

 4.Once yous are inside your project folder, Now let's create a strong name file past using following command as shown below.

sn -k Gacdemo.snk

 Y'all can replace "Gacdemo" with your own project proper noun or any proper name as per your requirement.

 Type "sn -1000 Gacdemo.snk" then press on Enter button.This volition create Gacdemo.snk (Strong Proper name Key File) in that folder.

 Potent name file consist of unique identity or private key with its version number, text name, public key, culture information and a digital signature.

Method 2 : Using Visual Studio IDE

Outset create any projection in your visual studio, One time your project is been created.

 GoTo-->Project(From Summit Carte of Visual Studio)-->ProjectName Properties equally shown in below paradigm.

Then become to-->Signing Tab-->Sign the assembly-->Give new strong name or select existing strong proper name.

After giving strong name to a DLL, Now its time to deploy an assembly (DLL) into GAC. There are diverse methods from which you tin deploy an assembly in GAC as shown below.

How to install or register an associates in GAC

1st Method

 Merely drag and drop/ CopyPaste an assembly to an associates folder.

 To discover an assembly folder start yous need to check your windows installation drive, In my case my windows is installed in "C-drive" then its "C" drive C:\WINDOWS\assembly.

2nd Method

 Using Microsoft .Internet Framework SDK v2.0/V.iv.0

 Make sure that you installed .Net Framework SDK v2.0/V.twoscore in your mechine. If not Please download from the below given url and install it.

 http://www.microsoft.com/en-us/download/details.aspx?id=19988 or http://www.microsoft.com/en-united states/download/details.aspx?id=8279

 1. Click Start > All Programs > Administrative Tools > Microsoft .Net Framework 2.0/4.0 Configuration.
two. Click Manage the Associates Cache.
3. Select Add an Assembly to the Assembly Enshroud.
4. Browse and select your DLL, which you desire to install it in GAC
5. Click Open. This volition deploy the selected assemblies into the Global Assembly Cache (GAC).
6. Restart the IIS.

3rd Method

 Open up upwardly visual studio command prompt non the windows command prompt.

So navigate to your assembly drive blazon drive proper noun and followed past colon i.e. d:

Then command "cd" followed by folder name i.e. cd assemblyfolder

GAC Command

Now in guild install/deploy an assembly in GAC using control prompt nosotros need to apply the following command as shown beneath

gacutil -i assemblyname

So at present that yous have understood about GAC, strong names and how to give strong proper noun to an assembly and steps to register an associates in GAC now its time to run into a simple code example of GAC.

Sample code example of Global Assembly Enshroud

Here in this code example, we will demostrate step by step from DLL cosmos and deployment of a DLL in GAC and how to utilize shared DLL (Registered DLL) in windows form application.

Step i - Create a C-Sharp Project

 Let's create a elementary C# projection

Pace two - Lawmaking a project

 Permit's add some coding to information technology

            public class CommonGac     {         public string MachineName()         {             return "My Machine Name is : " + Environment.MachineName;         }     }          

Step three  - Give a strong proper noun

 GoTo-->Project(From Top Menu of Visual Studio)-->ProjectName Properties as shown in below epitome.

Then become to-->Signing Tab-->Sign the associates-->Give new strong proper noun.

Nosotros have created a new strong name equally "CommonGacKey". Now lets save the project and build the project one time again.

As you lot come across friends a strong proper name cardinal file "CommonGacKey.snk" is been added to our project folder.

Step 4 - Create a new common folder

 In this stride nosotros will create a new mutual folder in the same drive or any other bulldoze.

 We have created a new binder chosen "GacCommon" in E-drive.

Step v - Motility the DLL to mutual folder

 In this step we will move the "CommonGac" projection DLL to a new binder "GacCommon" which we have created in Eastward-drive.

Step six - Deploy DLL in GAC

 To deploy an assembly or DLL in global associates enshroud we will apply our visual studio command prompt and our GAC command.

 i.e. gacutil -i assemblyname

gacutil -i CommonGac.dll

As y'all come across from our higher up snapshot that we have successfully added "CommonGac.dll" to GAC which was stored in E-drive GacCommon binder.

Step seven - Add new project

 Now nosotros have to add a new project "Windows Application or Web Application" to our existing C# project. In this scenario nosotros will add together "Windows Application".

Step 8 - Lawmaking the Windows Application Project

 First we will add a unproblematic button on Form screen so we volition reference the "CommonGac.dll" which nosotros accept saved in new folder "GacCommon" in Due east-Drive (because DLL present in "GacCommon" folder is got registered in GAC).

As yous see in our to a higher place image snapshot of solution explorer that we have referenced "CommonGac.dll" to our Windows Awarding Project.

Step 9 - Call the Course in Button Lawmaking

 In this stride we accept to import the namespace "CommonGac" and call the "CommonGac" course object in the button code as shown in the below snippet of code.

            using System; using Arrangement.Collections.Generic; using System.ComponentModel; using System.Data; using System.Cartoon; using System.Linq; using System.Text; using Organization.Windows.Forms; using CommonGac;  namespace WindowsFormsApplication1 {     public fractional class Form1 : Form     {         public Form1()         {             InitializeComponent();         }          CommonGac.CommonGac objGac;           private void button1_Click(object sender, EventArgs due east)         {             objGac = new CommonGac.CommonGac();              MessageBox.Testify(objGac.MachineName());          }     } }          

Finally build the windows awarding solution .

Pace 10 - Re-create the EXE to Whatever New Folder

 After building the windows application solution an exe file will be created inside bin\debug directory.

 Re-create that exe "WindowsFormsApplication1.exe" to whatsoever folder or any drive. Nosotros accept copied the "WindowsFormsApplication1.exe" to that common folder "GacCommon" in Due east-drive.

Step 11 - Finally Output

 Double click on "WindowsFormsApplication1.exe" to bank check the output. Allow'due south check the output.

Hey friends hope you understood most global assembly cache and steps to deploy an assembly into gac. In the further upcoming commodity we will also comprehend how to handle multiple versioning of DLL in GAC.

If you have any doubts kindly allow me know through your comments and kindly share this commodity with your friends on google+, facebook and twitter etc. Thank you

Author: Gurunatha Dogi

Gurunatha Dogi

Gurunatha Dogi is a software engineer by profession and founder of Onlinebuff.com, Onlinebuff is a tech blog which covers topics on .Internet Fundamentals, Csharp, Asp.Net, PHP, MYSQL, SQL Server and lots more..... read more

Comments


Add a Comment

Thank you, for commenting !!

Your comment is under moderation...

Keep reading other blogs

How To Register Oracle Dataaccess Dll In Gac,

Source: https://www.onlinebuff.com/article_how-to-deploy-an-assembly-into-gacglobal-assembly-cache-_38.html

Posted by: lairdhaddespeame.blogspot.com

0 Response to "How To Register Oracle Dataaccess Dll In Gac"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel