Moving DLLs from bin to GAC in asp.net
This must be a decade-old question, but surely come up to bite us again during the refactoring today. We decided to moved several shared DLLs from bin to GAC in several of our ASP.NET web sites. Here is what we found out:
- The code-behind files and the code in app_code directory failed to compile. The way to fix is add referenced assemblies to the compilation/assemblies section under system.web in web.config file. ASP.NET compiler will pickup DLLs in bin automatically but will not do so in GAC. We have to explicitly instruct it.
- If we update any DLL in GAC, we need to restart the application (e.g., using IISRESET) for APP.NET applications to pick up new versions of the DLL. ASP.NET shadows a copy of GAC DLLs in temp ASP.NET directory. While ASP.NET can detect DLL changes in the bin folder, it will not detect DLL changes in GAC until the application is restarted.
- Don’t even think of putting DLLs in both bin and GAC. There are well defined rules are which ones get actually used but doing so will only cause confusion. For more information, see http://stackoverflow.com/questions/981142/dll-in-both-the-bin-and-the-gac-which-one-gets-used.