1

I have to convert a very very simple program from Vb to C#. The Vb has those references enter image description here

From seeing here if I am not mistaken those should be managed dlls. I achieve the same result if I follow the procedure here with the dumpbin.exe program.

So everything should be fine. But when I do that CWorkpiece instance = new CWorkpiece(); I get the following error

enter image description here

which tells that the relevant dll is not in the right place. However the file is right were it should be enter image description here

That said I have thought that perhaps I had done a wrong investigation but adding the following lines didn't help

    [DllImport("C:\\Temp\\1\\Okuma.CLDATAPI.dll")]
    public static extern int CWorkpiece();

So in short the problem is all related with that dll which can't be found Thank you in advance for any help Patrick

Scott Solmer
  • 3,871
  • 6
  • 44
  • 72
Patrick
  • 3,073
  • 2
  • 22
  • 60
  • How did you add the reference before you tried to use DllImport? In the C# project, is there a little yellow triangle with "!" next to the reference? – Fildor Apr 04 '18 at 11:50
  • As far as I know the dllimport should be only for unmanaged dlls. So here should be not necessary. However I added them right click on the project references ---> add reference --> browse. And no, no yellow warning sign there (see pic 1). In fact in pic 3 the dll is present – Patrick Apr 04 '18 at 11:57
  • Try to make a new project. Add the reference and only one line with `CWorkpiece instance = new CWorkpiece();` - do you get the same error? – Fildor Apr 04 '18 at 11:59
  • Yes :-( same dll missing error – Patrick Apr 04 '18 at 12:10
  • Where is it located? Have you tried copying it into a folder inside the project structure and create the reference from there? – Fildor Apr 04 '18 at 12:14
  • Are those dlls available through nuget? – Fildor Apr 04 '18 at 12:15
  • I have also tried changing the location and also copying them into the folder. No those dlls are not available through nuget – Patrick Apr 04 '18 at 12:42
  • You may obtain them as a part of the [Okuma Open API SDK](https://github.com/OkumaAmerica/Open-API-SDK). – Scott Solmer Apr 05 '18 at 13:07

1 Answers1

1

Refer to Section "4.5.1.3.3.1 Missing library file" of the THINC API Installation Manual.

Ex Message

All applications developed with .NET THINC-API libraries are required to include an exact version of THINC-API libraries with the custom installation. THINC-API libraries compiled with application should be installed with your application folder.

The above error message shows that THINC-API library named Okuma.CLDATAPI.dll cannot be found at the folder where the application runs from.

Solution: Include THINC-API libraries compiled in your application with your custom setup and re-install your application with new setup.

Yes the THINC API libraries are managed .NET libraries. The command (CMD) API is written in VB, and the data API in VC++. Depending on the API version you have, these libraries either written in .NET 1.1 or 4.0. So you really shouldn't be attempting to Pinvoke them.

The real problem you are facing is attempting to run your program in an environment which does not have the THINC API installed. Yes, you have the libraries referenced by your application, but that is not enough.

The THINC API libraries have several dependencies including:

  • Okuma.FlexNet.dll
  • Okuma.ApiLog.dll / Okuma.Api.LogService.dll
  • LDATAPI.dll / MDATAPI.dll / GDATAPI.dll
  • LCMDAPI.exe / MCMDAPI.exe / GCMDAPI.exe
  • PIODlib.dll
  • Softswitch.exe

Solution

  1. Obtain a copy of the API Install disc; either from a disc that has shipped with an Okuma machine, or a new version through your Okuma dealer.

  2. Install the development version of the THINC API in your development environment.

Note that you will not be able to Init() or call any other API functions unless your environment is one of the following:

  • An actual Okuma Machine with CAPI Option and THINC API Installed
  • An "NC-Master" Simulator such as this: P300A NC-Master Simulator
  • Or a PC NC-Master which is an all software simulator.
Scott Solmer
  • 3,871
  • 6
  • 44
  • 72