MATLAB: Use of NationalInstruments.Tdms .Net assembly

licenseMATLABnet

In my project, I need to read all .tdms files (including files with Raw Daq MX data). As I have a Measurement Studio License, I thought that using the NationalInstruments.Tdms .Net assembly in matlab would be a convenient and powerfull solution.
This is the code I wrote :
NITdmsAssembly = NET.addAssembly('NationalInstruments.Tdms');
TdmsFileObj = NationalInstruments.Tdms.TdmsFile(TdmsFilePath,NationalInstruments.Tdms.TdmsFileOptions());
This the message error I get : Message: NationalInstruments.Tdms.TdmsLicenser is unlicensed. Source: NationalInstruments.Common HelpLink:
I try to find help on Internet. I found how to manage this issue in Visual Studio but nothing about matlab. Is there somebody who know how to deal with .Net Assemblies that need license in matlab ?

Best Answer

I found a solution using Visual studio to create the folowing .Net assembly with a class that just create the TdmsFileObj.
Here is the code of the assembly :
using NationalInstruments;
using NationalInstruments.Tdms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TDMS4Matlab
{
public class NI_TDMS_File
{
// properties
public string FilePathAndName;
public NationalInstruments.Tdms.TdmsFile myTdmsFile;
public System.Type type_double ;
// methods
// Constructor
public NI_TDMS_File(string FilePathAndName)
{
// memorisation of the file name
this.FilePathAndName = FilePathAndName;
// Creation of the TDMS File object
this.myTdmsFile = new TdmsFile(FilePathAndName, new TdmsFileOptions());
this.type_double = typeof(double);
}
// destructor
~NI_TDMS_File()
{
this.myTdmsFile.Dispose();
this.FilePathAndName = string.Empty;
}
}
}
In my matlab code, I just have to load my assembly (and the Nationnal Instrument ones). The tdmsfile object is inside my object and it is possible to use it with no additionnal effort. The license issue has disapeared by magic !
Related Question