Struct c# DLL

I'm showing how TestStand can recover data from a c# method DLL returning an array of type struct.

I created a custom type in TestStand corresponding to the .NET signature structure, but I keep running into the same error:

«No corresponding in the "Locals.newarray" argument type Subproperty 'Row' for the field 'struct .NET 'TestStandObjectArray.Row' k_BackingField.»

I put the ".NET Struct Passing" tab to "allow objects of this Type to be passed as .NET Structs.

I also tried "Exclude when passing struct" on this tab as well.

I enclose my DLL, file CS, TestStand and TestStand types.ini file sequence.

Any advice or assistance would be appreciated.

I think I see what is the problem. You did the members of properties instead of fields. Instead of:

public struct Row
{
public string mystring {get; set ;}}
public bool mybool; ;}
    
}

Try this:

public struct Row
{
public string mystring;
public bool mybool;
    
}

The notation you use '{get; '. together; '} ', is a shortcut to c# to declare a private field, you care about access from code directly (this is why it is named with k_BackingField) and a property to wrap it. TestStand struct passage works only on the field, not properties.

Hope this helps,

-Doug

Tags: NI Software

Similar Questions

  • Reference to Struct to DLL (library function call)

    I have two functions written in C, which takes the reference to a struct.

    Statements:

    IpAddress_Parse (IpAddress, address const kChar * text)

    ConnectIpAddress (connection, const kIpAddress * address)

    typedef struct IpAddress
    {
    int version;
    address to unsigned char [16];
    } IpAddress;

    Extracted from:

    Sub main (int argc, char * argv)

    {

    IpAddress ipAddress;

    IpAddress_Parse (& ipAddress, "12.0.1.10");

    ConnectIpAddress (connection, & ipAddress);

    }

    I'm trying to convert above in LabVIEW, but are struggling to. I tried to create a Cluster in LV and analyze the data of IpAddress_Parse() and pass it to ConnectIpAddress() as "Adapt to the Type" nothing helps. Even though I have artificially build a Cluster to move to ConnectIpAddress(), I mistake 1097 of LabView. My cluster included an int and a byte array that follows typedef struct IpAddress.

    Please provide some indication that what I'm doing wrong. Thanks in advance.

    Please submit your LabVIEW code. The IpAddress cluster must contain a 32-bit integer value and a nested group containing 16 U8 values. You can not replace an array of fixed length C with an array of LabVIEW; You must use a cluster containing the same number of items instead.

  • configuration dll when the parameter is of type STRUCT

    Hi all

    I use call library funtion to bind to one of the DLL, but my question is is the parameter to pass to STRUCT type and I do not know how to configure this feature.

    If you pass the struct by reference, then choose Yes, adapted to the Type.  It does not matter what you choose "Data Format", because the grapes are always passed by reference.  If you pass the struct by value, then pass each element of the structure as a separate parameter without using a cluster, as described here.

  • External DLL with struct array

    I am train (new to this) call an external dll.  The function prototype looks like this:

    int FUNCTION (int * count, struct List_t * list);

    Count is of type Long

    List_t is a structure that looks like:

    typedef struct List_t
    {
    char name [MAXCHARS];
    char file [MAXCHARS];
    double length;
    bool wired;
    bool DDD;
    };

    and the list is an array of length (MAX-1), where MAX is defined as 10 and MAXCHARS is 48.

    This is my last try:

    and I have the List parameter as "adapt to the type" and "pointer of table data.

    I get correct data, but not all.

    Thank you

    And increasingly what said tbob, you better make sure the entrance of County is never greater than 1, as the function could otherwise try to fill only element that you pass and what can AND will damage your memory eventually causing some breaks down, but has no need to plant immediately beyond the end of the table.

    What you should probably do is to replace the node Build array by Array Node initialization and son County control also at the entrance to the size of it. Set the number at 10 and use the number of output to resize the table using table to reshape the size that was filled in.

  • Passage Cluster containing strings in a C DLL in the Struct

    Hello everyone.

    I have a C DLL that I call you inside a Labview application.

    Some of the C functions use structs as inputs. These structures contain strings. The C DLL expects normal char * string type.

    Currently, I create a cluster that matches the structure and then passing in the DLL. It seems to work fine for everything except the strings. I think it has something to do with the operation of the library function call. Normally, you can select the format of string for strings as parameters. But given that you must use to adapt it to the type of parameter for the cluster, you seem to lose this control.

    I don't know exactly what I need to do to create the string of C, the DLL requires the chain of labview.

    Any help would be appreciated.


  • Strategies for bridge (structs) containers to the c dll table ++

    Does anyone have any suggestions for the passage of tables of containers (C structs) between TS and c ++ dll? I have exhausted my understanding here. I noticed that when I create a type which is an array of containers (size = 1), allow to move like a C struct but exclude the container as C struct, and then type presents itself as a struct rather than an array ref in the C++ dll parameters dialog box. I was hoping that I could exploit something here, but not luck.

    As a last resort, I could try to flatten the structures in an array of double, pass it as a VARIANT and rebuild on the other side - yuck!  I have hundreds of different transfers to manage that way, so I'm still holding hope for something better.

    In C/C++, I think that if you define a structure with a table like this:

    struct {Topic2

    int sizeVar;

    Topic1 array [size];

    }

    Then, the size is fixed. It doesn't really change because the compiler whenever you allocate a variable of the type of structure, must allocate enough space to store all the items that you have declared in the definition of struct. In other sizeof (Topic2) includes the full size of the array defined using the constant of 'size' that must be a constant, not a variable. If you want something more dynamic, you declare your structure as follows:

    struct {Topic2

    int size;

    Topic1 * array;

    }

    you dynamically allocate the memory for the array pointer and release it dynamically when you're finished with it.

    A simpler approach, that you can take, if the size range is quite small, is to make the Board as large as size max you will ever need and add another Member to say how many items in the table is actually being used. And it seems that your def struct is close to that, but not quite right. For example, I'm sure that you can not use the size for the variable field and the size of the array. Instead, you probably need something more like this

    struct {Topic2

    int numElements.

    Topic1 table [taille_max];

    }

    Hope this helps,

    -Doug

  • DLL and array of pointers to incomplete struct

    I think that this has probably been dealth with before, but I tried searching and have not found an answer that solved my problem.

    I have a function implemented in a DLL that returns a pointer to an incomplete structure.  Everything works very well.

    Now, I want to write a function that passes an array of the DLL (pre-allocated in LV) and fills that table with a set of pointers to the incomplete struct (same data as type works well on it).

    I can't get this to work.

    I tried:

    int function (struct incompletestruct * table) as a function prototype, but I get complaints of "unknown of the incomplete struct size" if I then try to reference table [value].

    I tried

    int function (struct incompletestruct * array []) as a prototype of function, but the LV crashes hard when what I call with setting "a pointer to the data in the table.

    I tried

    int function (struct incompletestruct * array [16]) as a prototype function, but even lock as indicated above.

    What combination of prototype of function and the convention in DLL call BT need me for this?

    I use LV 2009 SP1 and CVI 9.0.

    Shane

    I am not able to solve the complete problem, but can at least give a few tips:

    * Array of pointers is an array of I32 (I guess that's not true 64-bit more).

    * Hidden in the LabVIEW.exe there is some undocumented functions that allow to perform pointer operations. Somewhere, there should be a LabVIEW.h file. And just type in labview under the name of the dll in the call library node.

    * So the full concept would be to deal with pointers as I32 pass inside the LV and get pointer to data via these functions build-in

    Felix

  • LabVIEW dll call struct complex

    Hello

    I'm just creating a LabVIEW library for a Dll driver. The Dll contains complex structures. I just want to know if I can get around creating a wrapper Dll for these calls.

    It is an example of a function call:

    Error AA_querySlaveInfo (handle hSlave, SlaveInfo * pSlaveInfo,)

    int flags);

    typedef struct {}
    vendorId int;
    int productId;
    review of int;
    int series;
    const char * group;
    const char * image;
    const char * order;
    const char * name;
    int objCount;
    DataObjInfo * objs [1];
    } SlaveInfo;

    typedef struct {}
    the type of object int;
    const char * name;
    int bitLength;
    } DataObjInfo;

    Aid is quite aprechiated.

    Thank you

    Hi Keppi,

    This is not possible, sorry. Without the last entry in the struct that it would work, but this pointer to the another struct... you'll need a wrapper for it!

    I hope this helps,

    RMathews

  • struct dll to the cluster of LabVIEW

    Hello. Currently I'm trying to read the data struct dll writen and see the data in the cluster of LabVIEW, accordingly, I want to use this data in my project of futher. But I am facing a problem. The main problem is, that I can read the data, but those data are incorrect.

    Here is the structure of the dll:

    typedef struct PHAROS_MOTOR_CONTROLLER_state_tag
    {
    SYSTEMTIME TimeStamp;
    unsigned char MotorControllerState;
    unsigned long MotorPosition;
    MotorCurrent short unsigned;

    unsigned int AmbientHumidity;

    float moisture;
    float temperature;
    float point dew;

    float Detector_2Ph;

    } PHAROS_MOTOR_CONTROLLER_state;

    This is the function I try to call using the node library function call:

    bool PHAROS_API_Motor_Get_State (PHAROS_MOTOR_CONTROLLER_state * State)

    Returns the value true and fill State structure with the latest information from the State received from the motor controller or
    Returns false if no status message received or interval of time since the last receipt.
    This function returns immediately.

    So, maybe you have a suggestion how to recive correct cluster data?

    Thank you in advance!

    SIMAS

    It is quite easy to do and asked several times on this forum.  Despite Zoomzoomzoom comments, there is no need to write any sort of wrapper in C.  All you have to do is to create a cluster in LabVIEW that reproduces available to the C struct.  When you configure the call library function node, configure it as "Adapt to type" and the cluster thread entry for this parameter.  It will be automatically passed by reference (like a pointer).  The output of this parameter will be your data.  You may need to add a few items of padding to the cluster - struct elements in C are normally aligned, while clusters of LabVIEW are packed - but once you have this right, it will work.  You will need to replace the SYSTEMTIME component with an equivalent cluster within the plu cluster (search for SYSTEMTIME will show you that it is just 8 2 byte values).

    You should check if the header file includes a line #pragma pack(), which indicates if the structure is aligned in a non-standard way.  If it follows standard packaging, you will need to add 3 bytes of padding after MotorControllerState and 2 bytes after MotorCurrent.  I assume here that your DLL "int" and "long" are equivalent, even if MotorPosition is defined as long and AmbientHumidity is defined as int.

    If you are able to recover some data, but it is data incorrect, most likely, it's because you're missing the padding.  If you can not understand where the padding is necessary, or are unable to work, please attach your code showing what you're trying to do.

  • How to handle a function with struct return of dll?

    I have a dll 'SCTSCTL_OPEN' function returns a structure like

    typedef struct _sctsctl_t {}
    HANDLE hDevice;
    unsigned char ctl [2];
    unsigned long necessarily;
    unsigned long data_diff;
    HANDLE IsrThread;
    HANDLE IsrEventHandle;
    PVOID can't;
    void (* Manager) (struct _sctsctl_t * board, int intvec);
    } * sctsctl_t;

    SCTS_API sctsctl_t __stdcall SCTSCTL_OPEN (DWORD instance);

    I have imported this dll with LabVIEW and vi returns an unsigned long integer shown as follows.

    How to make a comeback with structure? Any help would be appreicated.

    Kind regards

    Adam

    LV 8.5.1

    Normally I would be tempted to do a wrapper function and call it with LV LV. handles structure not so naturally.

  • from struct with table of dll

    I have a dll with a function similar to the following, I have to call.

    16th #define CHIEF

    typedef UINT32 status;

    typedef UINT32 DeviceHandle;

    typedef struct SetRcvFilterReq
    {
    UINT16 mask [COUNT];
    } T_SetRcvFilterReq;

    typedef struct RcvFilterResp
    {
    Status of UINT16;

    } T_RcvFilterResp;

    API status API_CALL SetRcvFilter(DeviceHandle handle, T_SetRcvFilterReq rcvFilter, T_RcvFilterResp *response);

    I tried to manage it as it is descripbed in the Simple Struct "(with types of basic data); Passage of a parameter (passing by value)"I found here:

    https://decibel.NI.com/content/docs/doc-9079

    But it does not work to my problem. I still have the error 1097.

    Any ideas?

    Tobias_BSH wrote:

    Hi nathand!

    My problem is exactly the way I need to counfigure the COLD LAKE! The struct is passed by value, not by reference and it contains a table, so I don't know if I did it right. If I try to use a table or a cluster, the COLD LAKE alwas want to pass the reference value.

    Yes, I Traore error maximum control level and the COLD LAKE error 1097: "LabVIEW: an exception occurred in the external code that is called by a function of the call library node." The exception may have damaged the memory of LabVIEW. Save all work to a new location and restart LabVIEW. »

    It would be a fairly portable Setup. Passage of a struct by value means that all its individual components are passed on the stack. However, for an array of uint16, it raises the question if each uint16 is passed as a single parameter value or rather two uint16 combined in a setting from 32-bit to 32-bit LabVIEW and four uint16 combined into a 64-bit to 64-bit LabVIEW parameter. I would like to personallly assumes that it's the last. However, I'm not sure C actually mandates one above the other and it is quite possible that different C compilers do it differently (and some might even choose to promote to a pointer in any case!

    In short, standard C is quite vague in these things and leaves flexibility to the developers of the compiler for specific implementations. This isn't a defect of C, but on purpose to allow C compiler to the manufacturers to adapt their compiler in various ways to the real implementation that is best suited to a particular architecture of the CPU hardware. C is not even mandate that one byte is always 8 bits (and for some examples of hardware architecture arcane that it wasn't!)

    Personally, this API is something that although it can probably be made to work by the elements of the array of packaging in the elements for the target architecture and then pass them as parameters, individual service, is certainly something that I would trust never to be consistent between different C compilers (and same versions of C compiler).

    So try to create 8 16 uint16 values uint32 values and pass them as 8 individual function parameters (4 uint64 settings if you get to work in 64-bit LabVIEW). It can work, but is a horrible definition of the API.

  • Trouble accessing a struct returned a DLL function

    I realize, this is a recurring theme on the forums, but I've not been able to find a thread that has successfully helped me to solve my problem, here's so I write.

    I work with a third party dll to get x, y data z to a device. I'm having problems when you try to use the following C function (via call library node):

    int ArmGetTipPosition (length_3D * position);

    where:

    typedef float length;

    Is it possible that your DLL is really a full group of 0?  Maybe you need to call another function in the DLL first to get something initialized?  If the cluster that you place in the node library call contains values non-null, this does affect the output?

  • Function of dll to interface with struct in LabVIEW

    Hello

    I have a function:


  • Instrument LabWindows DLL in memory DLL handles

    I am rewriting some of the software of test of production for the company I work for. Development requires that I rewrite all instrument drivers placing them in a DLL. Then I re-wrote the functions test placing them in another DLL. Adding to what they were doing is adding TestStand to call the test functions in the desired sequence. The old code used the old sequencer LabWindows years ago. They insist to use the GPIB function calls rather than allow me to use the generic viWrite, viRead.

    I developed the instrument drivers so that the driver keeps track of the handles. Which worked find when I test the test functions LabWindows calling the functions of the unit. However, I have problems when calling thanks TestStand test functions. I put my instrument driver code to see what is happening MessagePopups. I see that the handle is here sometimes and not others. I guess that maybe TestStand create different instances of the code of the DLL (?). Anyway, I have add a pragma to see if that would cure the issue.

    struct AC_Power_Config
    {
    int ACPower_Device;
    int ACPower_GPIB_BoardIndex;
    int ACPower_GPIB_PrimaryAddress;
    int ACPower_GPIB_SecondaryAddress;
    int ACPower_GPIB_IOtimeout;
    int ACPower_GPIB_EOImode;
    int ACPower_GPIB_EOScharacter;
    };
    //
    #if defined (__AC_POWER_SUPPLY__)
    #pragma data_seg ("AC_POWER_SHARED")
    //
    int ACPower_GPIB_Handle = - 1;
    struct AC_Power_Config AC_Power_Configuration;
    //
    #pragma data_seg()
    #pragma how (linker, "/ section: AC_POWER_SHARED, RWS")
    #endif

    He did not. I don't know if I ironed the handle to TestStand to follow the handles if the handles would continue to operate.

    Are there instructions I put in my code LabWindows or some link that I can use to make sure that the handles are maintained in the area of DLL memory and options that all the function calls reference this memory? Any thoughts on the best way to deal with this would be appreciated. Although the change in the overall design (TestStand for DLL DLL) cannot be done.

    Thank you

    Hi Bill,

    I'm sorry to hear that you run in it, it seems like a strange behavior. Just to clarify, when you say "I see that the handle is here sometimes and not others" do you mean behavior varies according to the different tracks of the sequence or in a single pass, some handles are there, but others are not?

    Also, what do you call the DLL? I don't know if you have seen this already or not, but this KB can be useful in ensuring that it is no more than one instance of the DLL in memory at the same time:

    "Several Instances of dll or the sequence in memory files are possible with TestStand.

    http://digital.NI.com/public.nsf/allkb/6E1FF9F8EB5DCC0086256944004B90B0

  • TestStand can not find that all exported DLL functions

    Hi all

    My problem is the following:

    I have a DLL that I compile with Visual Studio with 40 functions. When I want to use this DLL in teststand, there are two missing functions. If I check with the dependency walker, the 2 missing function in teststand tool are well implemented.

    The missing function prototype:

    struct HModemBoardOpaqueType * mbCreateModemBoard (void)

    Good function prototype:

    enum UbtDllErrorCode mbDisconnectFromModemboard(struct HModemBoardOpaqueType *)

    Is that possible that teststand does not structure opaque type correctly?

    If I export my function type C (with extern C) no function is missing from the test bench

    Thank you

    What version of TestStand do you use? Older versions of TestStand only supported zero, digital and Boolean data types for the return values of the adapter of the dll. More recent versions of TestStand are now supported pointer/handle as well. New versions of TestStand I expect you can use such a prototype with the handle/pointer data type. However, if you want to convert this struct to an equivalent TestStand custom data type, you need to make a parameter instead of a return value, as the card does not support the conversion of struct for return values.

    Basically returning a struct pointer this way (as return value) is dangerous in C/C++, because it is not possible to know who owns the memory. The type of pointer/handle allows you to do anyway, but it must be properly to maintain life of memory return you at a lower level (i.e. maybe with an exported function that uses the pointer who knows how free it).

    Hope this helps,

    -Doug

Maybe you are looking for

  • credit card declined still even after paying

    I make my payment with another card to my pending purchase but I want to go back to my old account, but he writes payment refused even though I have make all my payment what should I do to repeat my previous card viable?

  • Access to the file refused to C++

    Sorry, this is my first time posting and I don't know what advice this should go. I'm developing an application C++ (MSVC) who reads PDM data and uses the nilibddc.lib to read the independent data.  I'm running into a problem if more than one copy of

  • How to add information in the body/attachment email with labview

    Hi, I did a project on the development of a game for seniors. It's something the breaker of brick where the elderly can adjust the size of the ball & speed. The game worked perfectly. If it works that way, when I press the button 'Quit' in the game,

  • Error system 1355: "Error_no_such_domain".

    Original title: Impossible to type my new password! I click on the start icon connected, and then click Control Panel. Then I click on user accounts. I click on the account which I want to change my password. I logged onto the account which I want to

  • My garden of Image with windows using 10 to scan from a canon printer mg5450

    I'm trying to use my kindergarten picture using windows 10 to scan from a canon printer mg5450 but I get mg5400 in my selection of scan and my printer is not recognized. Just downloaded and installed mp68-victory-mg5400-1_01-YES. Any suggestions plea