NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Acessing DotNet Form Class IN NITestStand

HI,

 I am exposing a method DetectATEInstruments() from a DotNet Dll

 autodetection() function internally creates a DotNet Form and displays and then on completion of autodetection it will get closed()

it's working fine when am Executing TPS for the first time ,it's creating the Form and disposing it sucessfully....

 

on second execution of TPS it throwing the following error

 

The .NET method 'DetectATEInstruments' threw an exception.

Cannot access a disposed object.
Object name: 'ProgressBarUpdate'.
Source:  System.Windows.Forms   at System.Windows.Forms.Control.CreateHandle()
   at System.Windows.Forms.Form.CreateHandle()
   at System.Windows.Forms.Control.get_Handle()
   at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
   at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
   at System.Windows.Forms.Control.set_Visible(Boolean value)
   at System.Windows.Forms.Control.Show()
   at Honeywell.CommonATE.SelfTest.ManipulateProgressBar.StartProgressBar(String message)

 

 

what could be the cause for this error.

 

Thanks in advance

 

bharathi

0 Kudos
Message 1 of 10
(4,530 Views)

It sounds like you are trying to reuse a Form object after you have already called Dispose() on it. You either need to stop calling dispose on it or you need to recreate it the next time you need it.

 

Hope this helps,

-Doug

0 Kudos
Message 2 of 10
(4,515 Views)

Hi diug,

Thankd for your time.

am recreatiung fresh Form object on every new run,it works from .net client fine and dandy.

but am facing the issue only in teststand.

 

 

Thanks

BHarathi

0 Kudos
Message 3 of 10
(4,490 Views)

Are you recreating and/or replacing the reference you are using in TestStand (if you are holding the reference in a TestStand variable)? Are you creating the object with the TestStand adapter or inside of a different code module? Are you returning it as an output parameter to TestStand? The TestStand sequence might be what is holding onto the old reference and reusing it.

 

If you can attach an example sequence and .NET assembly source code which reproduces the problem, we might be able to more quickly figure out what's wrong or determine if it is a bug in TestStand. I think in this case, an example will be the quickest way for us to help determine the problem.

 

Hope this helps,

-Doug

0 Kudos
Message 4 of 10
(4,478 Views)

Hi doug,

Thanks for your time

I fixed the issue ,the problem was due to test stand caching the old objects created and reusing the same.

 

 

Thanks

Bharathi

0 Kudos
Message 5 of 10
(4,465 Views)

Hi Bharathi,

 

TestStand does not generally cache the objects unless you have the "Use Step Load/Unload Options to Specify Object Creation Time and Lifetime" setting enabled on the create object subpanel. Did you have this setting enabled? Just want to make sure that what you are seeing is expected behavior. If you don't have this setting enabled then there should not be any caching and you should get a new object created whenever your step is run.

 

Hope this helps,

-Doug

0 Kudos
Message 6 of 10
(4,457 Views)

Hi doug,

 

The setting for unloadoption is default (ie.Unload when sequence file is unloaded)

i din't chnage the default one.this is the one u really ment.?

 

Thanks

Bhaathi

0 Kudos
Message 7 of 10
(4,454 Views)

No, the setting I'm talking about is a different one. It is on the .NET adapter module panel. Click on the button for creation options (where you choose which constructor to use).

 

-Doug

0 Kudos
Message 8 of 10
(4,443 Views)

ya got it....

tht is in default state.

i din't change it...

 

 

Thanks

bharathi

0 Kudos
Message 9 of 10
(4,437 Views)

It's unchecked then? If it's unchecked then I'm not sure why there would be any caching being done on the TestStand side. TestStand should recreate the object each time the step is executed if that is what you have it configured to do and aren't using this option. Anyway, if you're satisfied with how you have it working then that's fine. If you want us to look into it further to make sure there isn't a bug in TestStand, please attach an example sequence which reproduces the unexpected caching behavior.

 

Thanks,

-Doug

0 Kudos
Message 10 of 10
(4,427 Views)