Home > Net >  The Tag [] array into IntPtr parameter of type
The Tag [] array into IntPtr parameter of type

Time:04-03

NX second development, big trouble help have a look at how to modify, the whole thing out in a big recently,
 Args [] grip_arg_list=new Args [1]. 
The Tag [] obj=new Tag [2].
Grip_arg_list [0]. Type=UFConstants. UF_TYPE_TAG_T_ARRAY;
Grip_arg_list [0]. Length=2;
GCHandle IndicesHandle=GCHandle. Alloc (obj, GCHandleType. Pinned);//for a given object allocation specified type of handle
IntPtr s=IndicesHandle. AddrOfPinnedObject ();
Grip_arg_list [0]. Address=s;
IndicesHandle. Free ();

Debugging appear error:

124 line is this:
 GCHandle IndicesHandle=GCHandle. Alloc (obj, GCHandleType. Pinned); 


How do you change that?

CodePudding user response:

Should not need to use Alloc, try to create the object directly, converted to a pointer called a try,

CodePudding user response:

reference 1/f, rabbit party at large response:
should not need to use Alloc, try to create the object directly, converted to a pointer called a try,

You mean the casting directly? Grip_arg_list [2]. Address=(obj IntPtr); Is that so? Unable to convert IntPtr Tag []

CodePudding user response:

reference 1/f, rabbit party at large response:
should not need to use Alloc, try to create the object directly, converted to a pointer called a try,


Have a question want to ask you, is I need how to convert IntPtr after conversion back to Tag after to the corresponding calculation in [], or read IntPtr, pointing to the content?

CodePudding user response:

Marshal. StructureToPtr
This is converting a single object, why don't you try it
  •  Tags:  
  • C#
  • Related