Author Topic: Connecting with OPC driver  (Read 6461 times)

Rplink3r

  • Newbie
  • *
  • Posts: 5
    • View Profile
Connecting with OPC driver
« on: July 14, 2013, 04:26:31 PM »
Hello,

 I've tryed to connect to a Omron CX-Server OPC with integrated drivers, in the driver properties field OPC server I've written "OpenDataServer.ODOPCServer", as the server presents itself. Others I've left unchanged . I have set up a test tag named bit_TEST which toggles true/false each second. When I connect with some third party OPC viewer, it connects and works, but if I compile AdvancedHMI, it gives me following errors:

"A first chance exception of type 'System.InvalidCastException' occurred in OpcNetApi.dll"
"A first chance exception of type 'Opc.NotConnectedException' occurred in OpcNetApi.dll"

I'm stuck here, please help, probably I've set up something wrong?


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Connecting with OPC driver
« Reply #1 on: July 14, 2013, 04:59:20 PM »
Do you just see those messages in the immediate windows or does it stop the application?

Is it and OPC DA server or OPC UA? Are you using a 32 bit or 64 bit PC?

Rplink3r

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Connecting with OPC driver
« Reply #2 on: July 15, 2013, 02:18:51 AM »
The messages show in the immediate window, the application doesn't stop.

This is what I found in the documentation of the server:
"For OPC Client that is compliant with OPC Data Access version 2."

I suppose this stands for OPC DA, I have Windows 7 x64.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Connecting with OPC driver
« Reply #3 on: July 15, 2013, 07:43:10 PM »
Try this:

In Solution Explorer, right click AdvanedHMI and select properties.
Go to the Compile tab and look for Target CPU. Depending on your VS version, it may be in the Advanced Compile Options
Change the setting to x86

Rplink3r

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Connecting with OPC driver
« Reply #4 on: July 16, 2013, 07:29:18 AM »
Thanks,

That solved the problem, Changed to x86 following with the instructions below:

http://stackoverflow.com/questions/4104228/change-target-cpu-settings-in-visual-studio-2010-express

Now it works and I'm very happy with it, tryed it with Matrikon Simulation OPC and everything works.