NI Home > Community > NI Discussion Forums


Showing results for 
Search instead for 
Do you mean 
Posts: 5

C# wrapper error code 6202

I am writing a wrapper in C# to read TDM files.

OpenEx works fine.


[DllImport(lib, CharSet = CharSet.Auto)] static extern int DDC_OpenFileEx( [MarshalAs(UnmanagedType.LPStr)] string filePath, [MarshalAs(UnmanagedType.LPStr)] string fileType, int read_only, ref long file);



[DllImport(lib, CharSet = CharSet.Auto)] static extern int DDC_GetFileStringPropertyLength(long file,


string property, ref int length);



int len = 0;

errCode = ReadTDM.DDC_GetFileStringPropertyLength(fileh, "name", ref len);// fileh is passed form OpenEx fun

System.Console.WriteLine("length {0}", len);
System.Console.WriteLine("Error Code {0}", errCode);


 gives me an error  An invalid argument was passed to the library. I had tried ref uint length , didn't help.






Active Participant
Posts: 329

Re: C# wrapper error code 6202

We looked at the source code for DDC_GetFileStringPropertyLength and the only things that would cause it to

return DDC_InvalidArgument (-6202) is:

  • if the property name char* input parameter (2nd parameter) is NULL or empty string
  • if the length unsigned int* output parameter is NULL.


I'm not familiar enough with C# to tell whether there are any problems in the declarations of the DLL functions

or in how they are being called but maybe that helps you to solve the issue.

Posts: 5

Re: C# wrapper error code 6202

Thx for the reply.

I found out that I have two headers files nilibddc_m.h and nilibddc.h


in first one DDCFileHandle is a long type in the second on is a structure 


typedef struct _DDCFile DDCFile; typedef struct _DDCChannelGroup DDCChannelGroup; typedef struct _DDCChannel DDCChannel; typedef DDCFile* DDCFileHandle; typedef DDCChannelGroup* DDCChannelGroupHandle; typedef DDCChannel* DDCChannelHandle;


 but according to your post it should not be the cause of this error, should be?



Posts: 5

Re: C# wrapper error code 6202

some additional info:

Windows 7 32bit and lib form the 32-bit subfoler

example SinData.tdm form


and the String is not the problem



/// <summary> /// GetNumChannelGroups /// </summary> [DllImport(lib)] static extern int DDC_GetNumChannelGroups(long file, ref uint numChannelGroups);





uint numGru = 0; errCode = ReadTDM.DDC_GetNumChannelGroups(fileh, ref numGru); System.Console.WriteLine("Error Code {0} GetNumChannelGroups", errCode);


 also returs the -6202 code, hence is numGru.




Posts: 5

Re: C# wrapper error code 6202

Solved Smiley Happy


file must be int not long 


 nilibddc.h says


 typedef long            DDCFileHandle;
typedef long            DDCChannelGroupHandle;
typedef long            DDCChannelHandle;