NI Home > Community > NI Discussion Forums

DIAdem

Showing results for 
Search instead for 
Do you mean 
Reply
Member
luuuu
Posts: 5
0 Kudos

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.

 

 

 

 

 

Active Participant
AndreasK
Posts: 256
0 Kudos

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.

Member
luuuu
Posts: 5
0 Kudos

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?

 

 

Member
luuuu
Posts: 5
0 Kudos

Re: C# wrapper error code 6202

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.

 

 

 

Member
luuuu
Posts: 5
0 Kudos

Re: C# wrapper error code 6202

Solved :smileyhappy:

 

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;