NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

I need to pass the Strings using Sytem.collections.generic.dictionary type to c# code.

The following error comes up in TestStand 2021.

 

Object of type 'System.__ComObject' cannot be converted to type 'System.Collections.Generic.Dictionary
0 Kudos
Message 1 of 4
(1,452 Views)

Hello prakashs424,

 

Could you please attach a photo of the error, it will be more visual and understandable. Also, in which step you faced with this issue?

 

Best Regards  

0 Kudos
Message 2 of 4
(1,387 Views)

Hi,

You have to convert ComObject (PropertyObject) to .NET dictionary in your C# Code itself.

 

0 Kudos
Message 3 of 4
(1,381 Views)

Another possibility is to use a sequence with .NET adapter steps to create a dictionary from a TestStand data structure and store that in a TestStand object reference variable and pass it into the code module. The assembly that takes the generic dictionary type should have that type as one of the classes you can use in its "classes" list. You can use that to create a new instance of the dictionary and, in subsequent steps, call into the class to add values.

 

If you don't own the code you are calling and don't want to have to write C# code around it, it could be a good option.

 

-Doug

0 Kudos
Message 4 of 4
(1,374 Views)