NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

-17500 error when calling .NET method

Thanks in advance to anyone who can shed some light on this (even if just to confirm it to be a TestStand bug).
First off, I'm running TestStand 3.0 and using version 2.0 of the .NET Framework.
I have two sequences, both of which call two separate .NET methods each housed in a separate assembly. 
One sequence, "DNX1u_Config.seq", calls a .NET method "RunDialog" housed in the assembly (with namespace) SycamoreNetworks.DNX1U.DNX1U_Config_Dialog.
The other sequence, "DNX1u_BatchConfig.seq", calls another .NET method "RunBatchDialog" housed in a separate assembly (again prefixed with namespace) SycamoreNetworks.DNX1U.DNX1U_BatchConfig_Dialog.
Both methods accept similar arguments expect in the batch version, two of the arguments are arrays whereas in the other, they are not.
 
Here's where things get strange:
If I load both sequences into memory, and run them independently, the first one always works and the second always fails... regardless of which order I run them in!
 
It was initially giving me an error stating that it was expecting an array but received a single var or vice-versa (depending on which sequence I ran first).  It seems likely to me that, for whatever reason, TestStand was mistakenly expecting the second method to have the same argument list as the first call despite being completely separate methods in separate assemblies.
 
Interestingly, I then changed the argument list in one of the methods so that the parameter names were no longer identical, and now I get a different error:
"An error occurred within the .NET code. The .NET method 'RunDialog' could not be accessed. Object reference not set to an instance of an object. [Error Code: -17500, Operation Failed.]"
 
I have tried setting and not setting the object reference to a local object variable - neither with success.
 
Everything works fine if only one sequence is open at a time, but I do not wish to arbitrarily constrain my users in this way unless necessary.  Any ideas would be greatly appreciated.
0 Kudos
Message 1 of 4
(3,486 Views)
Rob,

It would be helpful to have a little bit more information about your assembly here.  For instance, are "DNX1U_Config_Dialog" and "DNX1U_BatchConfig_Dialog" the class names in which each function resides?  What exactly are the prototypes for these functions? 

In fact, it might be helpful if you attach the two assemblies.  Once I have this information, I can try and reproduce what you are talking about.
Thanks,

Andy McRorie
NI R&D
0 Kudos
Message 2 of 4
(3,465 Views)
Hi Rob,

I am having trouble reproducing this problem.  Can you post an example that will reproduce the problem?  Also, are you seeing this from the Sequence Editor or one of the OIs?  If from an OI, which one?  Do you only have .NET framework 2.0 installed or do you also have 1.1? 

Michael Dozier
NI
0 Kudos
Message 3 of 4
(3,463 Views)
I have discovered the root cause of this issue.  In both assemblies, a data structure "SelectionData" was defined at global scope - hence in the SycamoreNetworks.DNX1U namespace.  If I attempt to call both dialogs from a single VB .NET project, it gives me a useful error message - "'Selection Data' is ambiguous in the SycamoreNetworks.DNX1U namespace.".  Apparently, TestStand instead silently uses the first SelectionData data type loaded in memory.  This is why the first one always worked and the second always failed.  Clearly this is a flaw in my VB code.  Nevertheless, NI may consider providing (or maybe they already have in newer versions) more descriptive error messages when assemblies are loaded into memory containing ambiguous definitions.
Well, maybe this post will help out some other developer who inadvertantly makes the same mistake.
0 Kudos
Message 4 of 4
(3,442 Views)