Cannot Connect to NI OPC Server after Running the Application as a Service

Updated Nov 10, 2022

Reported In

Software

  • OPC Servers

Issue Details

I recently configured the NI OPC server to launch as a service by updating the ServerMain.ini file. Now when I launch the OPC Quick Client, I receive an error stating: Failed to connect to server ‘National Instruments.NIOPCServers’ (see image below). Additionally, I cannot connect to the NI OPC Server using LabVIEW. How can I fix this?

Solution

The root cause of the problem is that a registry key has not been properly deleted. To fix this issue follow the steps listed below (Windows 7 and Windows XP):
 
  1. Close the NI OPC Servers application and ensure that servermain.exe is not running in the task manager under Processes
  2. Stop the NI OPC Servers service through the Services control panel if it is started. To access the Services control panel, type services.msc into the Windows run dialog and click OK.
  3. Check to make sure that NI OPC Server is not set to run as a service.
    1. Navigate to the <National Instruments>\Shared\NI OPC Servers directory and open ServerMain.ini in a text reader such as Notepad.
    2. Find the line Start as NT Service.
    3. If Start as NT Service=0, then the OPC Server is currently not set to run as a service. If Start as NT Service=1, it is set to run as a service, and should be changed to Start as NT Service=0
Note: To change the INI file, you may have to change the permissions on the file.
 
  1. Open the Windows registry by typing regedit into the Windows run dialog. Delete the LocalService registry key under HKEY_CLASSES_ROOT\AppID\{6E617116-FF2D-11D2-8087-00105AA8F840}.
Note: Editing the registry can be dangerous. It is recommended that you first make a backup of your registry by exporting your settings under File»Export.
 
  1. Start the NI OPC Server by navigating to it in the start menu, Start»All Programs»National Instruments»NI OPC Servers or by running ServerMain.exe in the <National Instruments>\Shared\NI OPC Servers directory.
If none of the above steps work, you can uninstall and reinstall the DSC Module by referring to this link .

Additional Information

Note: If you try to launch the NI OPC Server as a service, but the Automatically start as a Windows NT service checkbox is grayed out and is not selectable, close the program and launch it again as an Administrator by right-clicking on its icon and selecting Run as Administrator.