I have two assemblies, created through conditional compilation (dev and real).
The public surface of these assemblies is 100% identical: both are strongly named; both are signed with the same .snk
and therefore have the same PublicKeyToken
; both have the same culture and the same version. I cannot change this: making them appear identical is the whole point.
However, on my machine the real assembly is in the GAC. I have an ASP.NET 3.5 WebForms app that references the dev assembly. It absolutely must do that; the real assembly crashes the app.
Is there a way to force a specific ASP.NET application to use the dev one (which is in /bin
), given that:
Version
and PublicKeyToken
.I noticed that someone already asked this in #991293, but the accepted answer involved removing the signing, which isn't an option here.
Am I out of luck?
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.
The Global Assembly Cache (GAC) is a central repository for storing shared assemblies. The GAC allows multiple versions of the same assembly to be installed concurrently and also prevents different assembly vendors from overwriting each other's assemblies.
GAC is always tried first, when binding assemblies: How the Runtime Locates Assemblies
So no, you can't do this. However if you explain why you have such strange requirements there might be a different work around, you have not thought of.
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.
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