Force .NET interop to use local COM DLL

前端 未结 3 1924
天命终不由人
天命终不由人 2021-02-03 14:10

Is it possible to force an interop assembly to reference a local copy of its associated COM DLL?

Here\'s the scenario:

I have a .NET app that references an inter

3条回答
  •  逝去的感伤
    2021-02-03 14:37

    Pavel pointed me in the right direction, so I will be marking his as the answer. For the benefit of everyone else, here's what I did:

    1. Added a reference to the original OTAClient.dll and let Visual Studio generate the interop library.
    2. Right-click on the referenced library in Solution Explorer and click Properties. Then set Isolated to True. This causes VS to generate a manifest file telling your program to look locally for your COM library instead of at the one listed in the registry.
    3. Specific to my scenario - I also had to reference WebClient.dll from Quality Center and set Isolated to True for that also. This is not used directly by apps using the OTA API, but seems to be referenced by OTAClient.dll.

    This way, you can be logging in and out of QC instances whose versions differ from the one used by your app without breaking it. In my case, I have a local QC instance that is v9 and used for project-specific automation (for various reasons, it's heavily customised to meet our needs, has lots of space for screenshot storage etc), and to which my application connects. However, for manual testing I also need to login using in IE to a v9.2 instance located elsewhere. If I had previously logged into the v9.2 instance, I would then have to open the v9 instance in IE and let it redownload the controls before running my app again... and now I don't. :)

提交回复
热议问题