How to force usage of built-in OPC proxies and stubs

From OPC Labs Knowledge Base
Revision as of 10:33, 18 January 2021 by User (talk | contribs)
Jump to navigation Jump to search

As explained in Prerequisites Boxing chapter in the User's Guide, QuickOPC uses “boxing”, a special technique based on file system and registry virtualization, which allows it to transparently load and use dependent software that would otherwise have to be installed (and uninstalled) separately.

QuickOPC uses this technique for multiple purposes. For OPC Classic, one of them is to get around a requirement to have the so-called OPC Core Components installed on the computer where program developed with QuickOPC is running. Normally, with OPC Classic, users are asked to download the OPC Core Components from https://opcfoundation.org/developer-tools/developer-kits-classic/core-components/ and install them; alternatively, OPC Core Components may be contained in an installation of some OPC Classic products.

The most important part of OPC Core Components are OPC Classic proxies and stubs. These integrate with COM/DCOM infrastructure, and are essentially DLLs that contain the code that allows marshalling OPC data between different processes and computers.

With OPC Core Components, QuickOPC uses a weak boxing. This means that if QuickOPC detects OPC Core Components on the computer where it runs, it will simply use them. But when OPC Core Components are not detected, application developed with QuickOPC will resort to boxing, and use its own, built-in version of the OPC Classic proxies and stubs.

In some cases it might be necessary or advisable to force the boxing of OPC Core Components, such as when an incorrect, faulty or incomplete version of the OPC Classic proxies and stubs is installed on the computer. By forcing QuickOPC to use the built-in proxies and stubs, you will ensure that a version that we believe works well is loaded.

To force the boxing of OPC Core Components for a QuickOPC application, add the following XML snippet under the <configuration> element of your application configuration file:

<appSettings>
    <add key="OpcLabs.EasyOpc.Boxing.Redistributables.OpcCorePSBoxer.WeakBoxing" value="false" />
</appSettings>

Please refer to Microsoft documentation for details on the application configuration files. The application configuration file needs to be named the same as your application, with an added “.config” extension, and placed alongside the application. For example, for “MyApp.exe”, the configuration file is “MyApp.exe.config”. Note that the development tools sometimes provide “shortcuts” for the naming and placing procedure. For example, Visual Studio C# projects contain an app.config file, which becomes the application configuration file automatically – Visual Studio copies it to the output folder and renames it appropriately.