addLicense -> NullReferenceException

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
Falbande
Jr. Member
Jr. Member
Posts: 1
Joined: 16 Nov 2022, 10:17

addLicense -> NullReferenceException

Post by Falbande »

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:

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);
                }
            }
Console output:

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.
License:

Code: Select all

<EncryptedLicense xmlns="http://www.unified-automation.com/licensing/">
 <ProductId>UaSdkNetEval-3.2.0_Eval-Win32-Binary</ProductId>
 ...
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!

User avatar
Support Team
Hero Member
Hero Member
Posts: 3064
Joined: 18 Mar 2011, 15:09

Re: addLicense -> NullReferenceException

Post by Support Team »

Hello,

We could not reproduce this issue.

Please create a sample application for reproducing and attach this project to a support ticket.
Best regards
Unified Automation Support Team

Post Reply