ApplicationLicenseManager.AddProcessLicenses Problem

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

Moderator: uasdknet

Post Reply
bradleyward
Sr. Member
Sr. Member
Posts: 11
Joined: 25 Nov 2013, 21:38

ApplicationLicenseManager.AddProcessLicenses Problem

Post by bradleyward »

I am evaluating the UA .Net Client SDK, and have been studying the Basic Client example. That seems to make sense, but to make sure, I wanted to create my own little sandbox program so that I could get the experience in writing a real example.

But I cannot seem to get past the ApplicationLicenseManager.AddProcessLicenses call.

First question: I have not been able to find documentation for the ApplicationLicenseManager class. it does not seem to show up in the Class List, or in the UaBase area. Is it documented somewhere, and if so, where?

Second question: The Basic Client application in the examples section includes a License.lic file in a "License" subfolder to the main folder where the source code is stored. But in the call to ApplicationLicenseManager.AddProcessLicenses, it is using a hard coded string of "UnifiedAutomation.Sample.License.License.lic". The argument to AddProcessLicenses is named "relativePath", but that string does not look like a relative path. How is the relativePath argument resolved, and where do I need to put the License.lic file for my sandbox program to work?

No matter what I have tried, every time my sandbox code calls AddProcessLicenses I am getting an ArgumentException, and the message says:

Path to resource does not exist.
Parameter name: resourcePath

What am I doing wrong?

Thanks,

Brad

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

Re: ApplicationLicenseManager.AddProcessLicenses Problem

Post by Support Team »

Hello Bradley,

The method AddProcessLicenses compares the argument recourcePath with all ManifestResourceNames of the assemly (See Assembly.GetManifestResourceNames). We recommend to use the full name (like "UnifiedAutomation.Sample.License.License.lic") or just the file name ("License.lic"). You must not use the second option if you have more than one embedded recourse with a name ending with "License.lic".

Best regards
Support Team

bradleyward
Sr. Member
Sr. Member
Posts: 11
Joined: 25 Nov 2013, 21:38

Re: ApplicationLicenseManager.AddProcessLicenses Problem

Post by bradleyward »

I got AddProcessLicenses working way back with the help of this thread on the forum.

But then today, I just upgraded to the version 2.3.0 SDK UA client. All I did was upgrade the UaBase and UaClient .Net DLL's to the latest version. My little test program now crashes with a NullReferenceException that is being thrown inside of the ApplicationLicenseManager.AddProcessLicenses() method. Both of my arguments look good going into the method.

Do I need to get an updated *.lic file to embed?

Perhaps I did something wrong, but the NullReferenceException seems to indicate something is not quite correct in the SDK code either.

Please advise.

Thanks,

Brad

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

Re: ApplicationLicenseManager.AddProcessLicenses Problem

Post by Support Team »

Hi Brad,

Yes, the .NET SDK v2.3.0 needs a new license file, which you can find in your download directory of v2.3.0

Best regards
Support Team

Earthed
Jr. Member
Jr. Member
Posts: 2
Joined: 18 Nov 2014, 23:05

Re: ApplicationLicenseManager.AddProcessLicenses Problem

Post by Earthed »

I have just downloaded all tools in early Nov 2014 and UA Modeller(1.3.3 "285") for VS2010 .NET 4.0 creates C# code (Program.cs:) with a License.lic file as follows:

<?xml version="1.0"?>
<EncryptedLicenseCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.unifiedautomation.com/licensing/">
<EncryptedLicense >
<ProductId>.NET OPC UA Server SDK 1.0.0 (BETA)</ProductId>

I used the recommendations in the post above to copy the License.lic file from ..\UaSdkNetBundleEval\examples\ServerGettingStarted\Lesson01\License\License.lic and it now starts up

I am still running in evaluation (unpaid)

In addition I also got a "InvaliOperationException crossed a native/managed boundary" on the execution of:
'ApplicationLicenseManager.AddProcessLicenses(System.Reflection.Assembly.GetExecutingAssembly(), "License.lic");'

To clear the error in VS2010, Goto Menu 'Tools\Options\Debugging\General\" and uncheck "Break when exceptions cross appdomain or managed/native boundaries..."

Post Reply