addLicense -> NullReferenceException
Posted: 16 Nov 2022, 10:48
Hi,
I am currently playing around with the .NET SDK to develop a small console application to list all available methods from an OPCUA server.
I am stuck at the ApplicationLicenseManager.AddProcessLicense() method, because of a NullReferenceException.
Source code:
Console output:
License:
I noticed, that the version number does not match the version of the assemblies, but this is also the case with the delivered examples.
-> Assembly version 3.2.1
What am I missing to get this program work?
Thanks in advance!
I am currently playing around with the .NET SDK to develop a small console application to list all available methods from an OPCUA server.
I am stuck at the ApplicationLicenseManager.AddProcessLicense() method, because of a NullReferenceException.
Source code:
Code: Select all
using System;
using UnifiedAutomation.UaBase;
using UnifiedAutomation.UaClient;
using System.Reflection;
namespace AMT_OpcUa_TestApp
{
/// <summary>
/// The main entry point for the application.
/// </summary>
internal class Program
{
[STAThread]
static void Main(string[] args)
{
//Get assembly:
Assembly assembly = Assembly.GetExecutingAssembly();
Console.WriteLine("Assembly.FullName: " + assembly.FullName + "\n");
Console.WriteLine("Assembly.Entrypoint: " + assembly.EntryPoint + "\n");
string[] embeddedResources = assembly.GetManifestResourceNames();
Console.WriteLine("Available Resources:");
foreach (var res in embeddedResources) {
Console.WriteLine("\t" + res);
}
Console.WriteLine();
if(assembly != null)
{
try
{
// Add license.
ApplicationLicenseManager.AddProcessLicenses(assembly, "AMT_OpcUa_TestApp.License.License.lic");
}
catch (Exception e)
{
Console.WriteLine(e.StackTrace);
}
}
Code: Select all
Assembly.FullName: AMT_OpcUa_TestApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Assembly.Entrypoint: Void Main(System.String[])
Available Resources:
AMT_OpcUa_TestApp.Properties.Resources.resources
AMT_OpcUa_TestApp.License.License.lic
System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
bei UnifiedAutomation.UaBase.ApplicationLicenseManager.AddProcessLicenses(Assembly assembly, String resourcePath)
bei AMT_OpcUa_TestApp.Program.Main(String[] args) in C:\projects\GitHub\AMT\AMT\AMT_OpcUa_TestApp\Program.cs:Zeile 39.
Code: Select all
<EncryptedLicense xmlns="http://www.unified-automation.com/licensing/">
<ProductId>UaSdkNetEval-3.2.0_Eval-Win32-Binary</ProductId>
...
-> Assembly version 3.2.1
What am I missing to get this program work?
Thanks in advance!