This is a mirror of official site: http://jasper-net.blogspot.com/

GAC In Visual Studio 2010

| Monday, December 13, 2010
When you create an application and compile it. It often generates a Dynamic Link Library (DLL) where you can have public methods to let other applications to use it. As you scale to medium to large enterprise, it seems natural to have some DLLs that should be used for more than one application. In fact, it sounds often popular to have various DLLs commonly used by various applications. How do you do that?

One way is to add a reference to the DLL in each app. In that case, if you have 10 apps that commonly use 4 DLLs; you need to add a reference to those DLLs on each one of the apps. So far so good. However, when you change the DLL, and most in-house DLLs get changed, you will need to redeploy it in all 10 apps.  You also may need to change one of those DLLs for one of the apps, but not for all 10 apps. Then, you may agree with me that under this scenario, you will need to start paying attention on what DLL is in what application and what version is being used by what App and BOOM! (explosion)…. You really got a hard maintenance job out there.

Well, windows has a common area called Global Assembly Cache (GAC) where you can add a DLL that can be used by any application on the server.  By using the GAC, you are going to maintain the DLL in one place.  That is less maintenance. In addition, the Article/snapshot below also shows you where and how to tell your app to use a DLL from a specific location instead of using it from the GAC. That may be useful when you want most of your applications to use the DLL from the GAC while a few apps or may be a specific app to use the DLL with the same name, but from another location than from the GAC.

The point also from this direct article is to show how to do that from a Setup program or Visual Studio installation program. In other words, you create and application and you are going to create an installation package to it. At that point, you want the setup to go ahead and add some DLLs that you application uses into the GAC.

How to do that in Visual Studio 2010? The answer is below:

The sample “snapshot” below targets a very specific audience (developer who needs to use the GAC and that know a bit about it from previous versions of Visual Studio):

Here it goes:

It is very simple.

  • First add a setup project to your application.
  • Next right click on the setup project in select view file system.
  • Next right click on the File System on Target Machine (under the File system tab) and choose add special folder and pick the Global Assembly cache folder.
  • Finally, right click on the Global Assembly Cache Folder and choose add to add the dll assemblies you want to be placed in the GAC.

Read more: Codeproject

Posted via email from .NET Info

0 comments: