Select to view content in your preferred language

Call to ArcGISRuntimeEnvironment.SetLicense throws an exception.

750
6
11-27-2023 10:33 AM
DagHeggelund
New Contributor

When I call sri.ArcGISRuntime.ArcGISRuntimeEnvironment.SetLicense(licenseString);
The result is Exception thrown: 'System.InvalidOperationException' in WinRT.Runtime.dll

Please advice.

0 Kudos
6 Replies
dotMorten_esri
Esri Notable Contributor

 Are you also seeing this if you just call ArcGISRuntimeEnvironment.Initialize() ?
If so it's most likely an issue with the native libraries not getting deployed.
What is your platform and target framework?

0 Kudos
BradleyJakobitz
Emerging Contributor

We are seeing a similar exception.  We are setting the license right before we initialize ArcGISRuntimeEnvironment.  This is nearly the first thing we do during app startup.  The ArcGISRuntimeEnvironment.IsInitialized is false just before setting the license.  We are targeting C# .Net 8.  If we don't try to set the license and just call ArcGISRuntimeEnvironment.Initialize() we don't see the exception.   Any suggestions are appreciated.

0 Kudos
dotMorten_esri
Esri Notable Contributor

Can you share the specific exception type, message and callstack?

0 Kudos
BradleyJakobitz
Emerging Contributor

Thanks for responding quickly.

ArcGISRuntimeEnvironment.SetLicense(@"runtimelite,1000,rud*****") is throwing System.InvalidOperationException: 'Operation is not valid due to the current state of the object.'

at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|38_0(Int32 hr)

The stack trace is small.  The HResult is -2147009196 if that helps at all.

0 Kudos
dotMorten_esri
Esri Notable Contributor

If you put a try/catch around the SetLicense call, will you get a better exception in the catch? I've seen some issues with Microsoft not always handling un-caught exceptions that well

0 Kudos
BradleyJakobitz
Emerging Contributor

Well, I feel foolish.  I had turned off Enable Just My Code for something else.  The exception must be thrown in a lower library and caught.  I'm unable to catch it and the license result comes back valid.  Thank you for your time.  Hopefully, this helps someone else.

0 Kudos