Problem:
Although example projects compile without errors, new projects fail and include the following Invalid Operation Exception: "An error occurred creating the form. See Exception.InnerException for details. The error is: Could not load file or assemble 'Kepware.ClientAce.OpcClient, Version=3.5.0.3, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format."
Possible Cause:
The ClientAce version 3.5 libraries are .NET 3.5 libraries. Visual Studio 2010 targets the .NET 4.0 environment by default.
Solution:
To create ClientAce version 3.5 projects in Visual Studio 2010, users must either set the target .NET environment to .NET 3.5 or include support for the 3.5 Client Interface in a .NET 4.0 targeted project.
Note:
The examples provided below work correctly because they target the right .NET Framework.
Targeting .NET 3.5 In VB.NET
- To start, open the project's properties.
- Next, open the Compile tab. Then, click Advanced Compile Options.
- In Advanced Compile Settings, change the target Framework to .NET Framework 3.5.
- Once finished, click OK.
Targeting .NET 3.5 in C#
- To start, open the project's properties.
- Next, open the Application tab.Then, change the target Framework to .NET 3.5 Framework.
- Once finished, save, close, and re-open the project.
Targeting the .NET 4.0 Framework
For information on using ClientAce .NET 3.5 libraries in a .NET 4.0 targeted project, refer to Can ClientAce Be Used with Visual Studio and the .NET 4.0 Framework?
Developing on a 64-bit Operating System
For information on using ClientAce on a 64-bit operating system, refer to Can I Develop ClientAce Projects for 64 bit Operating Systems?