With the DANSrv .NET Server Toolkit the OPC DA server development is reduced to the development of a .Net customization assembly with configuration definitions and device access methods.
The customization plug-in can be developed with Visual Studio 2005 and newer using either C# or Visual Basic, for either the .NET Frameworks 2/3.x or 4.x.
NSPlugin.dll should by built for 'ANY CPU' so that it can be used with either the 32bit or 64bit generic server executable.
There are multiple version of the generic server executable provided:
- DANSrv.exe for the .NET Framework 2 or 3.x
- DANSrvNet4.exe for the .NET Framework 4.x
The executables in the product installation directory are built for the X86 (32bit) platform.
The executables in the product installation X64 subdirectory are built for the X64 (64bit) platform. The file names are the same but the description in the file properties are different.
If you create applications with the Visual Studio 'New Project' template then the correct version of the generic server is copied into the application.
The sample applications are provided with projects for multiple Visual Studio versions.
The projects have a post build step that copies the generic server (DANSrv.exe or DANSrvNet4.exe) and configuration files into the project output directory. DANSrv.exe is copied from the project directory and if it's not there, from the parent directory.
To create 64-bit servers you need to overwrite the DANSrv.exe file in the Sample Applications subdirectory with the 64-bit version of DANSrv.exe from the X64 setup subdirectory or copy this file into the project directories.
New Project
A new server development project can:
-
Be created with the ADVOSOL\DANSRV new project template in Visual Studio 2005 or newer.
The wizard creates a new Visual Studio project with either skeleton code or sample code according the dialog selections. -
Be based on one of the sample applications
Copy the best fitted sample application into a new directory and make the following changes:-
open the copied project in Visual Studio and optionally change the solution and project name
-
open the file ServerAdapt.cs / .vb and change the server registration definitions in the method GetServerRegistryDef()
Unique GUIDs for the CLSID and APPID can be generate with the Visual Studio tool Create GUIDS -
open the Visual Studio project properties, select Configuration properties - debugging and change the Start Application path to DANSrv.exe respectively DANSrvNet4.exe in bin/Debug of the current project. Visual Studio defines an absolute path that still points to the project that was copied.
-
compile the project and for VB execute the Post Build event manually. The copied sample application now runs under a new ProgID.
-
make the functional program changes
-
.NET Framework Versions
The DANSrv toolkit is provided for all versions of the .NET Framework:
- .NET 2.0, 3.0, 3.5
The generic server DANSrv.exe in the setup directory (or the X64 subdirectory) works with NSPlugin.dll assemblies that are built for these Framework versions.
Build NSPlugin.dll with Visual Studio 2005 or when using Visual Studio 2008 or newer then build for the .Net 2.0/3.0/3.5 target platform.
- .NET 4.x
The generic server DANSrvNet4.exe in the setup directory (or the X64 subdirectory) works with NSPluginNet4.dll assemblies that are built for the .NET4.x platform.
Build NSPluginNet4.dll with Visual Studio 2010 or newer and select the .NET Framework 4.0/4.5 target platform.
Upgrade .NET2 DANSrv projects to .NET4
The upgrade can be made without changing the application code. The following is necessary:
- Replace the generic server DANSrv.exe with DANSrvNet4.exe
This file may be renamed to a meaningful application name. This is recommended for users that have different servers running on the same machine. The file description in the file properties can be checked to determine the version of the generic server.
- In the server plug-in Visual Studio project:
- Change the Assembly name from NSPlugin.dll to NSPluginNet4.dll
This name cannot be changed because DANSrvNet4.exe is compiled for this name. - Change the target .NET Framework to .NET4
- References may have to be changed to the .NET4 version of the referenced assembly.
- Make sure that the selected target platform is ANY CPU if the plug-in is to be used with either 32-bit or 64-bit generic server.
- Change the Assembly name from NSPlugin.dll to NSPluginNet4.dll
Server for 64-bit mode operation
The 64-bit edition of the DANSrv.exe/DANSrvNet4.exe generic server can be used with the same customization plug-in DLLs if the plug-in assembly is compiled for the ANY CPU target platform.
The 64-bit server requires 64-bit OPC Core Components. The provided Advosol OPC Core Components work in 32-bit and 64-bit mode.
The 64-bit mode server can be accessed from 32-bit applications and 64-bit applications.
Test provided test clients are .NET applications built for ANY CPU and run in 64-bit mode on x64 machines.