Is there a way to force the usage of a specific dll version? from the app.config?
(backstory) We are using SQL Compact 3.5, and cannot for business reasons (yea, I know) move to SQL Compact 3.5 SP1 for the moment. We have the System.Data.SqlServerCe and all the unmanaged dlls in our build directory, but if SP1 is installed, the app loads up and uses the SP1 managed dll (and by extension, I assume the unmanaged ones too).
The version number of the pre-sp1 dll is 3.5.0.0, the sp1 version is 3.5.1.0
I've set the reference to the System.Data.SqlServerCe to CopyLocal = true and Specific Version = true, but it still uses the SP1 version, even when the pre-sp1 version is in our build directory (assume its using the one from the GAC). I've tried adding the reference from the GAC, as well as manually going into the file system and referencing the dll directly.
(just to make it clear, clients are installing the service pack for other software that needs it, but we need to still run the pre-sp1 version even when the service pack is installed)
Is there any way to force .net to use the one we have in our build directory?
UPDATE:
I put an override in the app config like this question, but running the assembly binding log viewer gives me this:
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Projects\ConsoleApplication11\bin\Debug\ConsoleApplication11.exe.Config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Redirect found in application configuration file: 3.5.0.0 redirected to 3.5.0.0.
LOG: Publisher policy file is found at C:\Windows\assembly\GAC_MSIL\policy.3.5.System.Data.SqlServerCe\3.5.0.0__89845dcd8080cc91\publisher.config.
LOG: Publisher policy file redirect is found: 3.5.0.0 redirected to 3.5.1.0.
LOG: ProcessorArchitecture is locked to MSIL.
LOG: Post-policy reference: System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL
LOG: Found assembly by looking in the GAC.
LOG: Binding succeeds. Returns assembly from C:\Windows\assembly\GAC_MSIL\System.Data.SqlServerCe\3.5.1.0__89845dcd8080cc91\System.Data.SqlServerCe.dll.
LOG: Assembly is loaded in default load context.
It looks like the config for the 3.5.1 assembly in the GAC is overriding it. Any way of forcing the issue from my app.config?
I've found the solution. Looking at the link in Henk's answer (here), and the output of the fusion log, it seems that the 3.5 SP1 installer installs a publisher policy file that forces loading of the sp1 dll, even when the pre-sp1 dll is requested.
Putting this in the app.config tells .net to ignore the publisher policy, and ends up using the 3.5.0.0 version:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Data.SqlServerCe" publicKeyToken="89845dcd8080cc91" />
<publisherPolicy apply="no"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
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