I'm quite struggling when trying to to what follows.
I'm currently using an ActiveX, through an interop dll generated by Visual Studio (more precisely tlbimp, implicitly).
Different versions of this ActiveX exist, that sometimes add, remove, properties in the interfaces. If I want to change the version, I have to change the reference, recompile and so on.
I'd like to have a single version of my code. I remember that to drive Word for example, one can instantiate a word object via CreateInstance on Word.Application, and call methods, whatever the version. Calls being linked only at runtime. I'd like to do the same with the activeX I use, but I don't really know how to do that (btw, it's sage objets100c dll). I don't find it in the list of ActiveX, thus I'm not even sure I can do like for Word.Application.
Has someone a clue about how I could do that ? (might be a completely different solution, as my need is: having one code with no need to recompile).
Thank you in advance
If you have a corresponding *.tlb file, reference this one, not the dll. In the properties window of the reference, you can set the
Specific Versionproperty toFalseandEmbedInterop TypestoTrue(makes it more stable).If this does not help, you can try to create and access the object dynamically instead of adding a reference. You need either the
ProgIDof the COM type …… or the CLSID of the COM type (you may find them in the registry)
Then you can create and object with
Activator.CreateInstanceand assign it to adynamicto do late binding.You will get no IntelliSense for this
dynamicobject. If you specify non-existing members (method or property names), you can still compile and run your C# code; however, a run-time exception will be thrown when you attempt to access these members.