c# - Add Reference dynamically to my project -
I am developing an add-in for Microsoft Word. In my add-in, I am using reference to the file "Microsoft.Office.Interop.Word.dll" so that I can use the word object.
If Word 2007 is installed in the development machine, then version 12 is included in the file reference, the case has been established in 2010, the file should have version 14.
How can I create my add-in and what version of Word do I have installed on the machine (in other words your application automatically shows which version of the office is installed and automatic Use proper interop file as usual)? If your actual code is making reference to objects in a given assembly, then trying to hook into a different version can actually cause errors. (Like some method signatures have been changed). In most cases, different constructions will have to be created to target different DLL versions, and the user will have to set up the right build on the machine.
There are strategies that you can use to make it easy, like wrapping your set of calls to this library in a set of interfaces, and then two main "plugins" assemblies for the interface Provide implementation, but who target different DLLs when applying them. The software can load the implementation bindings dynamically from the configuration, as is the popular dependency injection framework. In this way, if a method signature changes from one version to another, you can change a single square and your remaining code will still work.
Comments
Post a Comment