Is there any way to force my asp.net application to load the assembly from local bin directory since there is another older version of the assembly with the same name in the gac?
I can't delete the gac version since other applications are using it and I am facing some difficulties when adding the newer version to the gac.
The best answer was that "The GAC is only useful if you register libraries which you're going to reuse." In other words, don't use it if you are not going to share libraries between different applications.
If you dont care that the assembly is actually in the GAC, but just loadable on the machine (from the appdomain) you can just use LoadAssembly with the assemblies name (strong, common, full, etc). If the assembly can be loaded by Fusion it will be and then you will know it exists.
Again, you cannot install an assembly into GAC unless the assembly is strongly named.
The syntax for using gacutil.exe to install an assembly in the GAC is as follows: In this command, <assembly name> is the name of the assembly to install in the global assembly cache. If gacutil.exe isn't in your system path, use Visual Studio Developer Command Prompt or Visual Studio Developer PowerShell.
You should share assemblies by installing them into the Global Assembly Cache only when you need to. As a general guideline, keep assembly dependencies private, and locate assemblies in the application directory unless sharing an assembly is explicitly required.
As a general guideline, keep assembly dependencies private, and locate assemblies in the application directory unless sharing an assembly is explicitly required. In addition, it is not necessary to install assemblies into the Global Assembly Cache to make them accessible to COM interop or unmanaged code.
No there is no way to do this. When loading an assembly the CLR will check to see if a DLL with an equivalent strong name is present in the GAC. If there is a matching assembly in the GAC it will pick the GAC assembly every time. There is unfortunately no way to override this behavior.
I found it
To force your application to read from local bin directory you have to remove signing from your assembly and then the application will load the assembly from bin.
Thanks Wyatt Barnett and murad.
Change the version number, strong name the assembly and reference the strongly named higher version you deploy with your solution.
The oldVersion configuration that is suggested by Muse VSExtensions works! You can use the strong name for the local assembly: Please look this page: http://msdn.microsoft.com/en-us/library/7wd6ex19.aspx
Basically in web.config add something like:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="DllName"
publicKeyToken="0123456789abc"
culture="neutral" />
<!-- Assembly versions can be redirected in app,
publisher policy, or machine configuration files. -->
<bindingRedirect oldVersion="2.0.0.0-2.5.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
That way if i have an assembly in the gac that can be from version 2.0.0.0 to version 2.5.0.0 all the calls would be redirected to the newVersion (3.0.0.0)
In the assemblies section I added the assembly:
<add assembly="DllName, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0123456789abc" />
And that's it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With