From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

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);

 but

 

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

[MarshalAs(UnmanagedType.LPStr)]

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.

 

 

 

 

 

0 Kudos
Message 1 of 5
(5,187 Views)

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.

0 Kudos
Message 2 of 5
(5,146 Views)

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?

 

 

0 Kudos
Message 3 of 5
(5,120 Views)

some additional info:

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

example SinData.tdm form http://digital.ni.com/public.nsf/allkb/A3663DE39D6A2C5A86257204005C11CA?OpenDocument

 

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.

 

 

 

0 Kudos
Message 4 of 5
(5,115 Views)

Solved 🙂

 

file must be int not long

 

http://digital.ni.com/public.nsf/allkb/A3663DE39D6A2C5A86257204005C11CA?OpenDocument 

 

 nilibddc.h says

 

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

 

 

0 Kudos
Message 5 of 5
(5,052 Views)