.NET Based OPC UA Client/Server SDK  3.3.3.537
Setup a new Client Project

New Visual Studio Project

Create a new C# project of typ Windows Form App (.NET Framework) with the target framework .NET Framework 4.5.

NewClientProject_VisualStudio.png
Create a new Windows Forms project

We start our UA-Client aka Form1 at another position. Therefore, delete the marked line from the file Program.cs.

static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1()); // delete this line
}

Setup NuGet Packages

To setup the OPC UA .Net SDK Nuget Package Repository

  1. Go to menu Tools > NuGet Package Manager > Package Manager Settings
  2. In the left tree select Package Sources (0)
  3. Add a new package source with pressing the green cross button (1)
  4. Add the Source path to the NuGet packages (2).
    The packages are located at D:\UnifiedAutomation\UaSdkNetBundleBinary\NuGetPackages by default.
  5. Choose a name of your choice. (3)
  6. Finish and update the package source. (4)
NewProject_SetupNugetPackages_CratePackageSource.png
Create NuGet package source

Install Nuget Packages

To install Nuget packages in your project

  1. Go to menu Tools > NuGet Package Manager > Manage NuGet Packages for Solution ...
  2. Select the Browse "tab" - if not already selected.
  3. Select the created package in the Package Source-Combobox in the right upper corner.
    NewProject_SetupNugetPackages_SelectDotnetSdk.png
    Select UA .Net SDK NuGet repository
  4. Install needed packages. For this server example install the packages:

Don't forgett to add the using for UaBase at the end of the using-block in Program.cs.

Add a License File

At first add a new folder in your solution named License.

NewClientProject_AddLicense_AddExistingItem.png
Add existing item

Normaly you would use your purchased license file, but for evaluation and for this example you can take the license from our code samples located by default in D:\UnifiedAutomation\UaSdkNetBundleBinary\src\examples\UaBasicClient\License.
To see the license file set the filter to All Files (*.*), select the license file and confirm with clicking the button Add.
The license file will be copied to your project's license folder.

Note
Consider, that with the evaluation license the client will stop after one hour!
NewClientProject_AddLicense_AddFile.png
Add license file

To finish the task you have to set the BuildAction of the license file to Embedded Resource.

NewClientProject_AddLicense_SetBuildAction.png
Set BuildAction to 'Embedded Resource'

Use License in code

To use the license, you must add it to the LicenseManager. Therefore, add the following code in main() in Program.cs.

static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
try
{
ApplicationLicenseManager.AddProcessLicenses(System.Reflection.Assembly.GetExecutingAssembly(), "License.lic");
}
catch (Exception e)
{
}
}

Configure Product

To configure your client you have to provide a configuration file. Add an App.config file from an example project to your project. Same procedure as with the license file above. You can take it e.g. from D:\UnifiedAutomation\UaSdkNetBundleBinary\examples\BasicClient.
For more information on configuration settings, see the Base Library documentation at Configuration Schema.

Finally, you must set the BuildAction of the file to None.


Start ApplicationInstance

To finish this example and make your client start, add the following method to Program.cs, where Form1 is the automatically created form when creating the new project.

static class Program
{
...
// code to start the application
[STAThread]
static void Run(object userState)
{
System.Windows.Forms.Application.Run(new Form1());
}
}

Now add the following code to the main method whicht calls to start ApplicationInstance

static class Program
{
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
try
{
ApplicationLicenseManager.AddProcessLicenses(System.Reflection.Assembly.GetExecutingAssembly(), "License.lic");
ApplicationInstance.Default.Start(Run, null); // Add this line
}
catch (Exception e)
{
}
}
...
}