开发者

Is it necessary to put the shared assembly in GAC only?

I 开发者_如何学运维want to share a dll in between two projects.

Is it necessary to put the dll in GAC only or can I place it in any folder?


I would strongly recommend to keep it in the Bin folder of each Project. Do not attempt to share it unless that is really (really) necessary.

The second best option is to put in a shared folder (using a relative path) and configure that in each Projects config file (Probing path). Note that you will always have to update the 2 projects simultaneously. If the assembly holds types that are used to communicate between the 2 projects then that makes sense, but otherwise it is a needless complication.

The very last option is to put it into the GAC


The assembly loader will look for the assembly in several places, one of which is the execution directory.

This means that you can simply copy to multiple directories.

See How the Runtime Locates Assemblies on MSDN.


In your situation I'd recommend using your source control system to enforce structured sharing, not the GAC.

The process in Subversion:

  1. put the shared library in a single location in your source repository.
  2. In each of your two projects use svn:externals to pull in the shared library.

This gives you the best of both worlds:

  • a single spot in source control to update the shared library (like the GAC)
  • flexibility of private bin folder deployment (like not using GAC).
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜