Looking for wrong version of Microsoft.BizTalk.Interop.SSOClient

I have upgraded a server from BTS2013 to BTS2013r2. Following the upgrade I installed BTDF v6.

When I try to make the call: SSOSettingsFileReader.ReadString

I get the following exception:
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in SSOSettingsFileReader.dll

Additional information: Could not load file or assembly 'Microsoft.BizTalk.Interop.SSOClient, Version=7.0.2300.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
The problem is, it's looking for version 7 but I have version 9 installed in the GAC (which is the correct version for 2013r2).

I can see from your source code that you have 3 versions of SSOSettingsFileReader. The BTS2013 version looks for V7 of Interop.SSOClinet whereas the BTS2013r2 version looks for V9. So it seems in my case, the wrong version of your SSOSettingsFileReader is being
loaded. Could you tell me how the version to be loaded is determined?

You'll need to reinstall the Deployment Framework v6 on the machine where you build your app MSI's, rebuild an MSI then reinstall/redeploy to the server. The deployment will then GAC the correct version of the DLL.

I think the problem may have been caused by the fact that the BizTalk server previously had BizTalk 2013 installed. This was
upgraded to 2013r2 rather than uninstall / re-install. Consequently, the server had "c:\ Program Files (x86)\BizTalk 2013" and "c:\ Program Files (x86)\BizTalk 2013r2" folders in place. Does the installation process decide
which version of the DLL to install based on the presence of these folders?

The BTDF installer looks at the BizTalk registry keys at SOFTWARE\Microsoft\BizTalk Server\3.0 and grabs the product name. The product name is used to determine which files to install, and v6.0 is the first to recognize the 2013 R2 product name. The BizTalk
installation folder isn't referenced.

Thanks Tom. I can only think that the VM I was having trouble with had "Microsoft BizTalk Server 2013" for this registry value. Unfortunately I removed everything and re-built at the weekend so I can't be sure. Anyhow, good to know what determines
the version that gets installed.