Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

Issue with QuickOPC and Microfost.Office.Interop in WinForms

More
11 Jun 2024 12:34 #12866 by support
Hello.

I tested with 64-bit Excel from Microsoft Office Professional Plus 2021. But it is unlikely that the issue depends on the Excel version. More likely it has to do with Windows version. I tested under Windows 11, version 23H2.

You need OPC Core Components redistributables, from opcfoundation.org/developer-tools/samples-and-tools-classic/core-components/ .
After download, unzip, and run the .MSI for 64-bits.

Best regards

Please Log in or Create an account to join the conversation.

More
10 Jun 2024 17:56 #12864 by laritello
Hello! Thank you for your response!

Suggested changes helped with Excel and it's working. However, the OPC component is the one that causes exceptions now (see below):
Class not registered
This error may be caused by damaged or missing OPC Server registration on the specified computer.
It can also be due to a problem with OPC proxies/stubs, which can be resolved by installing OPC Core Components (from OPC Foundation).
The machine name was '127.0.0.1'. The server class used was '{7bc0cc8e-482c-47ca-abdc-0fe7f9c6e729}'.
Execution details: HasNativeClient=False, HasNetApiClient=True, ProcessBitness=64.
The client method called (or event/callback invoked) was 'ItemChanged'.

From the user's guide I understood that I need to manually install some components, but I can't figure out what exactly I need to install. Can you please provide me some help with this?

P.S. I'm curious what version of Excel did you use in your previous tests and was it 32-bit?

Please Log in or Create an account to join the conversation.

More
08 Jun 2024 16:41 #12860 by support
Hello.

Thank you for the videos and the project. The steps and the symptoms are clear. I was able to build and run the same. However, in my tests, I never received the error you are getting.

Without a repro, this becomes kind of shooting in the dark. There is one thing I'd like you to try out: Please following the instructions in this KB article: kb.opclabs.com/How_to_disable_prerequisites_boxing and retest. We have issues with that 3rd party library from time to time, and it is worth disabling it in order to rule out that it is the cause itself.

Best regards

Please Log in or Create an account to join the conversation.

More
07 Jun 2024 14:58 #12859 by laritello
I've updated the app to use the latest NuGet package. Still having the same issue. Video and code for the updated version attached.

OPC.mp4

File Attachment:

File Name: ExcelOPC64...6-07.zip
File Size:99 KB
Attachments:

Please Log in or Create an account to join the conversation.

More
05 Jun 2024 19:12 #12849 by support
Hello.

The issue is reported with QuickOPC internal version 5.63, which is QuickOPC 2022.1 (kb.opclabs.com/Versions ), no longer officially supported.
Upgrade to the current QuickOPC version. If the issue persists, we will investigate.

Best regards

Please Log in or Create an account to join the conversation.

More
05 Jun 2024 16:18 #12847 by laritello
Hi everyone! My issue is that Excel crashes the application when used with OPC client.

Installed:
  1. Windows Server 2012
  2. Microsoft Office 2010 Professional (32-bit version)
  3. Kepware ServerEX 6

Application info:
  1. Target framework: .NET 4.7.2
  2. Target platform: x64

Application references:
  1. Microsoft.Office.Interop.Excel v15.0.4795.1001
  2. OpcLabs.BaseLib v5.63.162.1
  3. OpcLabs.BaseLibForms v5.63.162.1
  4. OpcLabs.EasyOpcClassic v5.63.162.1
  5. OpcLabs.EasyOpcForms v5.63.162.1

Details:
In the application we’re using Microsoft.Interop to read data from Excel. It worked fine with previous OPC component, but after switching to a new one it started crashing with similar errors.

The example of an error:
System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Excel.Range'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00020846-0000-0000-C000-000000000046}' failed due to the following error: Interface not registered (Exception from HRESULT: 0x80040155)

After investigation, it looks like Excel stops working after attaching a handler to the ItemChanged event:
easyDAClient.ItemChanged += EasyDAClient_ItemChanged;

However, if during OPC client initialization we use:
easyDAClient.InstanceParameters.EnableNativeClient = false;

The errors don’t appear right away and Excel is usable. However, “Unable to cast error” still returns later. Our guess it happens after ItemChanged callback is triggered for the first time.

The error doesn't occur if the target platform is set to AnyCPU or x86.
However, certain constraints prevent us from implementing these changes.
Video of the demo and its source code are attached. Any ideas, what may cause this behaviour and how to fix it? Thank you in advance.

File Attachment:

File Name: ExcelOPC64.zip
File Size:22,256 KB

ExcelOPCx64Demo.mp4

Attachments:

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.059 seconds