DANSrv Reference
Development Steps
Send comments on this topic.
DANSrv OPC DA .Net Server Toolkit > Overview > Development Steps

Glossary Item Box

Component Description
Create a project It is recommended to use one of the Advosol\DANSRV new project templates to create a new application project.
To create a new custom project with a wizard, start Visual Studio, choose create new project and select the Advosol\DANSrv project template. The wizard creates a project with small sample code and file/identifier names as defined in the user dialog. It also creates unique GUIDs for the server.


Item Configuration The items supported by the server can be defined in the code of the customization module. Another way supported by the Professional Edition, is to use the ConfigBuilder Tool to interactively create an XML file with all the item configuration definitions.


Server registration

The wizard generated projects and the sample server projects register the server in the post build step.
If the server files are copied then execute the RegServer.exe utility in the project output directory in elevated administrator mode.

To register the server as a Windows service:
- create a shortcut to DANSrv.exe and add the command line argument /Service.
- execute the shortcut in elevated administrator mode

To unregister the server, execute the UnregServer.exe utility in the project output directory in elevated administrator mode. This unregisters the server from COM and as a Windows Service.

Testing the generic OPC Server The wizard generated project is a functional OPC server. It can be compiled and accessed from OPC clients. For this to make sense it has to be created with sample code enabled. In this case the server creates a few items and increments some of these items periodically.
Without sample code the server is functional but without items and therefore clients cannot do much else then checking the server status.

Debugging the Customization

To debug the server, it is started in debug mode in Visual Studio. Since the customization module is a DLL, the generic server exe has actually to be started. The wizards make the necessary project definitions.
The VS project stores the name of the start application as an absolute path. If the project is copied then the path of the start application has to be adapted in the project properties.

The customization method GetServerRegistryDef() is called at startup.
The initialization methods GetServerParameters() and CreateServerItems() are called when the first client connects. Normal server operation starts after these method calls are executed.

Deployment

The server EXE and the customization DLL need to be in the same directory and the RegServer.exe utility must be executed in this directory.
To copy the server to another computer you need to:
- copy Core Components setup file from the DANSrv installation OPC subdirectory and run it to install the OPC proxys and OPCEnum.EXE
- copy the DANSrv.EXE/DANSrvNet4.exe, NSPlugin.DLL/NSPluginNet4.dll, RegServer.exe and necessary configuration files from the output directory of the VS project into the application directory
- execute RegServer.exe once to register the server
- depending on security settings you may need to modify the configuration using the DCOMCNFG utility

Important: Server registration write the Windows Registry. Make sure that the server registration is executed in elevated administrator mode for registry write permissions.

 

DCOM Configuration If more than one user does access the server then it's advisable to assign a specific launching user for this server. This is done with DCOMCNFG. If this is not done then multiple instances of the server may run in different users. As long as only one user accesses the server at any given time then this is normally no problem. However if multiple user access concurrently then multiple instances of the server will be launched. For the client this makes no difference but the server's device communication may not work properly .

© 2002-2017 Copyright Advosol Inc. All Rights Reserved.