I created fresh projects for this as a proof of concept but I cannot get it to work.
I created a ClassLibrary1.dll with a simple method in it, at version 1.0.0.0. I created a WindowsFormsApplication1 that calls that method, also at version 1.0.0.0. I created associated setup projects for each solution and installed the MSIs. Everything good so far.
Then, I incremented all the version numbers of ClassLibrary1 to 1.0.1.0. I created a config file to redirect to the new version:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="ClassLibrary1" publicKeyToken="99e3abf647b4f724" culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="1.0.1.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
I used that to create a policy.1.0.ClassLibrary1.dll publisher policy with this command:
al /embed:ClassLibrary1.dll.config /out:Policy.1.0.ClassLibrary1.dll /keyfile:TestKey.snk /platform:anycpu /v:1.0.1.0
I inserted that into the GAC, both using the setup program, and manually after the DLL was installed by the setup program. Both ways the result is the same: A gacutil /l policy.1.0.ClassLibrary1 returns one instance of the policy in the GAC, but running the program fails to use the new version.
C:\Program Files (x86)\Liberty Testing\ClassLibrary1>gacutil /l Policy.1.0.ClassLibrary1
Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.30319.0
Copyright (c) Microsoft Corporation. All rights reserved.
The Global Assembly Cache contains the following assemblies:
Policy.1.0.ClassLibrary1, Version=1.0.1.0, Culture=neutral, PublicKeyToken=99e3abf647b4f724, processorArchitecture=MSIL
Number of items = 1
Though, I would note that manually looking in C:\Windows\Assembly does not show that the policy assembly exists anywhere in that subtree. I uninstalled all the libraries and reinstalled just the new version, and the program now crashes instead of using the new DLL. The fuslogvw output looks like this:
*** Assembly Binder Log Entry (6/26/2017 @ 2:31:59 PM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
Running under executable C:\Program Files (x86)\Liberty Testing\Test Form\WindowsFormsApplication1.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = DOMAIN\user
LOG: DisplayName = ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=99e3abf647b4f724
(Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/Liberty Testing/Test Form/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : WindowsFormsApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config.
LOG: Post-policy reference: ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=99e3abf647b4f724
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
ERR: Unrecoverable error occurred during pre-download check (hr = 0x80070002).
It does not appear to be looking at for a publisher policy at all. We have spent days trying to figure out what we are doing wrong. Does anyone else have any ideas?