Using a GAC-registered assembly in a web application
-
Hello , I am currently working on a project which requires the use of a custom dll for authentication. This dll is registered (so they told me) in the GAC of both the Production and Test environments. The company policies state that you "shouldn't include the dll reference in your application's web.config file", that is, you shouldn't have something like : etc. in your web.config, at least for this dll I am talking about. They say, since it's registered in the GAC, the application will load it anyway. The problem is , if you don't add the assemby reference in your web .config , the application is not going to find it , no matter what they say. Since I am sure the dll is actually registered in the GAC, my question is : shouldn't the application be able to load the dll anyway , no matter if you add the reference in the web.config or not ? I was convinced that, adding the reference to the project, the dll 's GAC location would be stored in the application's assembly so that the application itself would be able to find the assembly in the GAC , no matter what the working system is , given that the dll is actually registered in the working system's GAC . But I must be wrong. What is the real way it works ? Thanks Leo
-
Hello , I am currently working on a project which requires the use of a custom dll for authentication. This dll is registered (so they told me) in the GAC of both the Production and Test environments. The company policies state that you "shouldn't include the dll reference in your application's web.config file", that is, you shouldn't have something like : etc. in your web.config, at least for this dll I am talking about. They say, since it's registered in the GAC, the application will load it anyway. The problem is , if you don't add the assemby reference in your web .config , the application is not going to find it , no matter what they say. Since I am sure the dll is actually registered in the GAC, my question is : shouldn't the application be able to load the dll anyway , no matter if you add the reference in the web.config or not ? I was convinced that, adding the reference to the project, the dll 's GAC location would be stored in the application's assembly so that the application itself would be able to find the assembly in the GAC , no matter what the working system is , given that the dll is actually registered in the working system's GAC . But I must be wrong. What is the real way it works ? Thanks Leo
Global Assembly Cache | Microsoft Docs[^]
MSDN wrote:
The Global Assembly Cache stores assemblies specifically designated to be shared by several applications on the computer.
tiwal wrote:
I was convinced that, adding the reference to the project, the dll 's GAC location would be stored
The GAC location doesn't need to be stored; it is managed by the .NET environment. You will still need to add a reference to the dll. The difference is that you no longer have to copy the dll to the local output folder (which VS does for you, usually), but that the app will use the one that is registered in the GAC.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
-
Global Assembly Cache | Microsoft Docs[^]
MSDN wrote:
The Global Assembly Cache stores assemblies specifically designated to be shared by several applications on the computer.
tiwal wrote:
I was convinced that, adding the reference to the project, the dll 's GAC location would be stored
The GAC location doesn't need to be stored; it is managed by the .NET environment. You will still need to add a reference to the dll. The difference is that you no longer have to copy the dll to the local output folder (which VS does for you, usually), but that the app will use the one that is registered in the GAC.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
Hi Eddy thanks for answering. You mean that I still need the tag in the application's web.config ? Doesn't the application's assembly contain a reference itself ? The production cluster specialists in my company scolded me for putting the tag in the web. config, but then I showed them how it would behave without it, and they were baffled ....
-
Hi Eddy thanks for answering. You mean that I still need the tag in the application's web.config ? Doesn't the application's assembly contain a reference itself ? The production cluster specialists in my company scolded me for putting the tag in the web. config, but then I showed them how it would behave without it, and they were baffled ....
tiwal wrote:
You mean that I still need the <add assembly="" ...=""> tag in the application's web.config ? Doesn't the application's assembly contain a reference itself ?
It does for WinForms; the references are part of the project-file, and compiled into the assembly. I'd assume ASP.NET does the same. How the Runtime Locates Assemblies | Microsoft Docs[^] seems to suggest that the config-files are the first location where the runtime looks.
tiwal wrote:
The production cluster specialists in my company scolded me for putting the <add assembly="" ..=""> tag in the web. config
Why? Any specific reason why it is considered "bad"?
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
-
tiwal wrote:
You mean that I still need the <add assembly="" ...=""> tag in the application's web.config ? Doesn't the application's assembly contain a reference itself ?
It does for WinForms; the references are part of the project-file, and compiled into the assembly. I'd assume ASP.NET does the same. How the Runtime Locates Assemblies | Microsoft Docs[^] seems to suggest that the config-files are the first location where the runtime looks.
tiwal wrote:
The production cluster specialists in my company scolded me for putting the <add assembly="" ..=""> tag in the web. config
Why? Any specific reason why it is considered "bad"?
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.