License Exception When Targeting x64 Platform Using Measurement Studio

Updated Feb 21, 2023

Reported In

Software

  • Measurement Studio

Other

Visual Studio 2019

Issue Details

I have a C++/CLI application that communicates with a .NET application that uses Measurement Studio 2019 within the same project in Visual Studio 2019. When I run the program targeting the x86 platform, it runs correctly but when targeting the x64 it throws an exception during runtime when initializing a component. The exception pop-up shows the following error message:

System.Windows.Markup.XamlParseException: "Set property 'NationalInstruments.Controls.Primitives.GraphBase.DataSource' threw an exception.'

Inner Exception
LicenceException: 
NationalInstruments.Controls.Internal.WpfStandardLicenser is unlicensed.
 
Exception user unhandled.png

Solution

The issue is caused by the inlining methods in 64-bit. To work around this issue it is needed to disable or reduce the inline optimization done by the 64-bit JIT compiler. Follow these steps to reduce optimization on the DLL that is causing the issue:

1. Locate the folder where the DLL throwing the exception is (NationalInstruments.Controls.Graphs.dll). You can locate the folder by using the Fuslogvw.exe (Assembly Binding Log Viewer). You can also see the path from which the DLL is being referenced by going to the Solution Explorer >> References >> Assembly >> Properties >> Path.
 
Path.png
 
2. Add an .ini file to the folder where the NationalInstruments.Controls.Graphs assembly is installed. The .ini file should be named NationalInstruments.Controls.Graphs.ini and contain:

[.NET Framework Debugging Control]
GenerateTrackingInfo=1
AllowOptimize=0

Note: There are some performance implications due to the loss of inlining that need to be taken into account if using this workaround in production code. Since this ini setting is on an assembly in the GAC (usually), all applications that use the NationalInstruments.Controls.Graphs assembly would be affected. You might be able to reduce the scope by copying assemblies and using the ini file locally.