<p>And on top of that, are there cases where one has to use the global assembly cache or where one cannot use it?</p>

[{'answer_id': 23586, 'author': 'Vaibhav', 'author_id': 380, 'author_profile': 'https://Stackoverflow.com/users/380', 'pm_score': 2, 'selected': False, 'text': '<p>In all my life, I have had maybe one application where I had to put an assembly in the GAC, simply because these assemblies were part of a framework that a number of applications would use it, and it seemed right to put them into the GAC.</p>\n'}, {'answer_id': 23587, 'author': 'jonezy', 'author_id': 2272, 'author_profile': 'https://Stackoverflow.com/users/2272', 'pm_score': 3, 'selected': False, 'text': "<p>I think one of the biggest advantages of using the GAC is that you can have multiple versions of the same assembly registered and available to your applications.  Personally, i don't like how it restricts movement from machine to machine (i don't like having to say, check out source on a new VPC and go through a bunch of steps to get it running because I have to register stuff in the GAC)</p>\n"}, {'answer_id': 23598, 'author': 'lubos hasko', 'author_id': 275, 'author_profile': 'https://Stackoverflow.com/users/275', 'pm_score': 6, 'selected': False, 'text': "<ul>\n<li>Loading assemblies from GAC mean less overhead and security that your application will always load correct version of .NET library</li>\n<li>You shouldn't ngen assemblies that are outside of GAC, because there will be almost no performance gain, in many cases even loss in performance.</li>\n<li>You're already using GAC, because all standard .NET assemblies are actually in GAC and ngened (during installation).</li>\n<li>Using GAC for your own libraries adds complexity into deployment, I would try to avoid it at all costs.</li>\n<li>Your users need to be logged as administrators during installation if you want to put something into GAC, quite a problem for many types of applications.</li>\n</ul>\n\n<p>So to sum it all, start simple and if you later see major performance gains if you put your assemblies into GAC and NGEN them, go for it, otherwise don't bother. GAC is more suitable for frameworks where there is expectation for library to be shared among more applications, in 99% of cases, you don't need it.</p>\n"}, {'answer_id': 23599, 'author': 'Eduardo Molteni', 'author_id': 2385, 'author_profile': 'https://Stackoverflow.com/users/2385', 'pm_score': 5, 'selected': False, 'text': "<p>Advantage: </p>\n\n<ul>\n<li>Only one place to update your assemblys </li>\n<li>You use a little less hard drive space</li>\n</ul>\n\n<p>Disadvantage: </p>\n\n<ul>\n<li>If you need to update only one website, you can't. You may end with the other websites in the webserver broken</li>\n</ul>\n\n<p>Recommendation: Leave the GAC to MS and friends. The gigabyte is very cheap now.</p>\n"}, {'answer_id': 23602, 'author': 'Michael Stum', 'author_id': 91, 'author_profile': 'https://Stackoverflow.com/users/91', 'pm_score': 3, 'selected': False, 'text': '<p>The GAC runs with Full Trust and can be used by applications outside of your Web App. For example, Timer Jobs in Sharepoint HAVE to be in the GAC because the sptimer service is a separate process.</p>\n\n<p>The "Full Trust" Part is also a possible source for security issues. Sure, you can work with Code Access Security, but I do not see too many Assemblies using CAS unfortunately :( The /bin Folder can be locked down to Medium which is normally fine.</p>\n\n<p>Daniel Larson has a <a href="http://daniellarson.spaces.live.com/blog/cns!D3543C5837291E93!937.entry" rel="noreferrer">post on CAS as well</a> which details the differences a bit more.</p>\n'}, {'answer_id': 23635, 'author': 'Kev', 'author_id': 419, 'author_profile': 'https://Stackoverflow.com/users/419', 'pm_score': 4, 'selected': False, 'text': '<p>The GAC can also be used by assemblies that require elevated permissions to perform privileged operations on behalf of less trusted code (e.g. a partial trust ASP.NET application).</p>\n\n<p>For example, say you have a partial trust ASP.NET application which needs to perform a task that would require elevated privileges, i.e. <em>Full Trust</em>. The solution is to put the code that requires elevated privileges into a separate assembly. The assembly is marked with the <code>AllowPartiallyTrustedCallers</code> attribute and the class that contains the privileged logic is marked with the PermissionSet attribute, something like this: </p>\n\n<pre><code>[PermissionSet(SecurityAction.Assert, Unrestricted=true)]\n</code></pre>\n\n<p>Our assembly would be given a strong name (signed) and then deployed into the GAC.</p>\n\n<p>Now our partially trusted app(s) can utilise the trusted assembly in the GAC to carry out a specific and narrow set of privileged operations without losing the benefits of partial trust.</p>\n'}, {'answer_id': 1024152, 'author': 'Alex Yakunin', 'author_id': 106042, 'author_profile': 'https://Stackoverflow.com/users/106042', 'pm_score': 3, 'selected': False, 'text': '<p>If you\'re shipping a reusable library consisting of multiple assemblies, but only few of them form a facade, you can consider installing the assemblies into GAC, if the package is installed to developer\'s PCs. </p>\n\n<p>Imagine, you ship 6 assemblies, and only one of these 6 assemblies contains a facade - i.e. other 5 are used only by the facade itself. You ship:</p>\n\n<ul>\n<li><strong>MyProduct.Facade.dll</strong> - that\'s the only component intended to be used by developers</li>\n<li>MyProduct.Core.dll - used by MyProduct.Facade.dll, but not intended to be used by developers</li>\n<li>MyProduct.Component1.dll - the same</li>\n<li>MyProduct.Component2.dll - the same</li>\n<li>ThirdParty.Lib1.dll - third-party library used by MyProduct.Component1.dll</li>\n<li>ThirdParty.Lib2.dll - the same</li>\n<li>etc.</li>\n</ul>\n\n<p>Developers using your project would like to reference just <strong>MyProduct.Facade.dll</strong> in their own projects. But when their project runs, it must be able to load all the assemblies it references - recursively. How this can be achieved? In general, they must be available either in Bin folder, on in GAC:</p>\n\n<ul>\n<li>You may ask the developers to locate your installation folder and <strong>add references to all N</strong> assemblies you put there. This will ensure they\'ll be copied into Bin folder to be available in runtime.</li>\n<li>You may install VS.NET project template <strong>already containing these 6 references</strong>. A bit complex, since you should <em>inject</em> the actual path to your assemblies into this template <em>before</em> its installation. This can be done only by installer, since this path depends on installation path.</li>\n<li>You may ask developers to <strong>create a special post-build step in .csproj / .vbproj file</strong> copying the necessary dependencies to Bin folder. The same disadvantages.</li>\n<li>Finally, you may <strong>install all your assemblies into GAC</strong>. In this case developers must add the reference just to MyProduct.Facade.dll from their project. Everything else will be available in runtime anyway.</li>\n</ul>\n\n<p>Note: last option doesn\'t make you to do the same while shipping the project to production PCs. You can either ship all the assemblies within Bin folder, or install them into GAC - all depends all your wish. </p>\n\n<p>So the solution described shows the advantage of putting third-party assemblies into GAC during the development. It doesn\'t related to production.</p>\n\n<p><em>As you may find, installation into GAC is mainly intended to solve the problem of location of required assemblies (dependencies). If an assembly is installed into GAC, you may consider it exists "nearby" any application. It\'s like adding path to .exe to your PATH variable, but in "managed way".</em>  - of course, this is rather simplified description ;)</p>\n'}]
['https://Stackoverflow.com/questions/23578', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2374/']