Skip to main content
1-Visitor
June 13, 2016
Solved

Unable to load DLL 'twApi.dll'

  • June 13, 2016
  • 10 replies
  • 8035 views

We are trying to set up a OPC DA connection. After installing and configuring the extension from the installation manual, we get the below error messages when starting the OPC client service? The error repeats every 15 seconds.

2016-06-12 23:19:02.085Z [L: Information] [T: 1] [U: SYSTEM] [O: com.thingworx.services.HostService] Initializing Service...

2016-06-12 23:19:03.205Z [L: Information] [T: 1] [U: SYSTEM] [O: com.thingworx.services.HostService] Initialization complete.

2016-06-12 23:19:03.327Z [L: Information] [T: 4] [U: SYSTEM] [O: com.thingworx.services.HostService] Starting Service...

2016-06-12 23:19:03.422Z [L: Information] [T: 4] [U: SYSTEM] [O: com.thingworx.services.HostService] Service started.

2016-06-12 23:19:04.052Z [L: Error] [T: 5] [U: SYSTEM] [O: com.thingworx.communications.client.TwApiWrapper] Error initializing the .NET SDK. : System.DllNotFoundException: Unable to load DLL 'twApi.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)     at com.thingworx.communications.client.TwApiWrapper.twW_SetLoggerProperties(TwApiLogLevel level, Byte isVerboseEnabled, TwLogMessageDelegate onLogMessage)     at com.thingworx.communications.client.TwApiWrapper.ConfigureTwApiLogger()     at com.thingworx.communications.client.TwApiWrapper.Initialize(ClientConfigurator config)

2016-06-12 23:19:19.083Z [L: Error] [T: 5] [U: SYSTEM] [O: com.thingworx.communications.client.TwApiWrapper] Error initializing the .NET SDK. : System.DllNotFoundException: Unable to load DLL 'twApi.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)     at com.thingworx.communications.client.TwApiWrapper.twW_SetLoggerProperties(TwApiLogLevel level, Byte isVerboseEnabled, TwLogMessageDelegate onLogMessage)     at com.thingworx.communications.client.TwApiWrapper.ConfigureTwApiLogger()     at com.thingworx.communications.client.TwApiWrapper.Initialize(ClientConfigurator config)

What have we forgotten?

Regards, Jan

Best answer by BABA-SHYAM

First of all make sure you have "tw" folder which contains Newtonsoft.Json.dll, thingworx-dotnet-common.dll and two folders "x64" and x"86" which contains twApi.dll in it.

 

Now as seen in attached image you have to set property (Copy to local directory) of all above 4 dlls as "copy always" in the file property.

 

Build the solution and run. You wont see this error anymore.

10 replies

1-Visitor
June 13, 2016

Jan, can you try Riaan's answer marked as correct from the following thread 43992 ?

Let me know if this helps.

jmaasland1-VisitorAuthor
1-Visitor
June 13, 2016

We are not programming ourselves, just installing the OPC-DA client. So this does not help us.

5-Regular Member
June 13, 2016

Jan, what version of the OpcDA client are you running? Can you open/ edit 'ThingWorxOPCService.exe' and scroll down to the <switches> flag and change the value from Information to Verbose. Please post the new set of logs as well.

jmaasland1-VisitorAuthor
1-Visitor
June 13, 2016

The version is 5.6.1.1100.

How can I change the logging switch? It is an executable.

jmaasland1-VisitorAuthor
1-Visitor
June 13, 2016

I have found the switch. It is in the config file of the executable.

I don't think it makes any change in the logging.

2016-06-13 17:31:27.439Z [L: Information] [T: 1] [U: SYSTEM] [O: com.thingworx.services.HostService] Initialization complete.

2016-06-13 17:31:27.454Z [L: Information] [T: 4] [U: SYSTEM] [O: com.thingworx.services.HostService] Starting Service...

2016-06-13 17:31:27.517Z [L: Verbose] [T: 5] [U: SYSTEM] [O: com.thingworx.services.HostService] Using Platform uri: wss://192.168.11.105:8443/Thingworx/WS

2016-06-13 17:31:27.579Z [L: Error] [T: 5] [U: SYSTEM] [O: com.thingworx.communications.client.TwApiWrapper] Error initializing the .NET SDK. : System.DllNotFoundException: Unable to load DLL 'twApi.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)     at com.thingworx.communications.client.TwApiWrapper.twW_SetLoggerProperties(TwApiLogLevel level, Byte isVerboseEnabled, TwLogMessageDelegate onLogMessage)     at com.thingworx.communications.client.TwApiWrapper.ConfigureTwApiLogger()     at com.thingworx.communications.client.TwApiWrapper.Initialize(ClientConfigurator config)

2016-06-13 17:31:27.579Z [L: Information] [T: 4] [U: SYSTEM] [O: com.thingworx.services.HostService] Service started.

2016-06-13 17:31:42.600Z [L: Error] [T: 5] [U: SYSTEM] [O: com.thingworx.communications.client.TwApiWrapper] Error initializing the .NET SDK. : System.DllNotFoundException: Unable to load DLL 'twApi.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)     at com.thingworx.communications.client.TwApiWrapper.twW_SetLoggerProperties(TwApiLogLevel level, Byte isVerboseEnabled, TwLogMessageDelegate onLogMessage)     at com.thingworx.communications.client.TwApiWrapper.ConfigureTwApiLogger()     at com.thingworx.communications.client.TwApiWrapper.Initialize(ClientConfigurator config)

2016-06-13 17:31:57.608Z [L: Error] [T: 5] [U: SYSTEM] [O: com.thingworx.communications.client.TwApiWrapper] Error initializing the .NET SDK. : System.DllNotFoundException: Unable to load DLL 'twApi.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)     at com.thingworx.communications.client.TwApiWrapper.twW_SetLoggerProperties(TwApiLogLevel level, Byte isVerboseEnabled, TwLogMessageDelegate onLogMessage)     at com.thingworx.communications.client.TwApiWrapper.ConfigureTwApiLogger()     at com.thingworx.communications.client.TwApiWrapper.Initialize(ClientConfigurator config)