I have Computer A with Office 2016 installed - including Office COM libraries to develope apps - Excel Object Library was used to create an app (Microsoft.Office.Interop.Excel ver 15.0.0.0 included in GAC) - great, app works great.
I have computer B with Office 2007 installed - it includes Excel COM libraries in its GAC - ver 12.0.0.0 and ver 14.0.0.0. I want to run my app (from computer A) on this computer.
I added App.config file to my WPF app as follows:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Office.Interop.Excel"
publicKeyToken="71e9bce111e9429c"
culture="neutral" />
<bindingRedirect oldVersion="15.0.0.0"
newVersion="12.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="office"
publicKeyToken="71e9bce111e9429c"
culture="neutral" />
<bindingRedirect oldVersion="15.0.0.0"
newVersion="12.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
So I am trying to use older version of both libraries on computer where older version of Office in installed. I read that it is possible to set older version as the value of newVersion="". I include myApp.exe.config in my deployment but app still screams that it seems Excel not installed.
I simply removed \n from assemblyIdentity and bindingRedirect in App.config and it works now:
<dependentAssembly>
<assemblyIdentity name="Microsoft.Office.Interop.Excel" publicKeyToken="71e9bce111e9429c" culture="neutral" />
<bindingRedirect oldVersion="15.0.0.0" newVersion="12.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="office" publicKeyToken="71e9bce111e9429c" culture="neutral" />
<bindingRedirect oldVersion="15.0.0.0" newVersion="12.0.0.0"/>
</dependentAssembly>