NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Object returned by GetSequenceFileViewMgr?

According to TestStand Reference manual, Chapter9, a multiple window application can invoke GetSequenceFileViewMgr to determine whether a Sequence File View Manager control is displaying the sequence file. However, the returned value of GetSequenceFileViewMgr() is an object, which is a System.__ComObject in VB.Net. Although I try to cast it to AxSequenceFileViewMgr type, the application raise an exception of Invalid type cast.
What can I do if I want to access data member of AxSequenceFileViewMgr from the returned object?

Thanks for your help..
0 Kudos
Message 1 of 9
(4,033 Views)
Cast it to a SequenceFileViewMgr, as in the following snippet:



Object fileMgrObject = this.axApplicationMgr.GetSequenceFileViewMgr(sequenceFile);

if (fileMgrObject != null)
{
SequenceFileViewMgr fileMgr = fileMgrObject as SequenceFileViewMgr;

string fileName = fileMgr.GetCaptionText(CaptionSources.CaptionSource_CurrentSequenceFile, true, "");
}
0 Kudos
Message 2 of 9
(4,026 Views)
Thank you, James

Your suggestion indeed works in case of non-NULL object reference returning.
TestStand help manual indicates that GetSequenceFileViewMgr() will return null if a sequence file is not selected in a SequenceFileView Manager control.My current issue is I have no ideal on how to handle a NULL object referece. There seems no "null" in VB.Net, and either

If Me.axApplicationMgr.GetSequenceFileViewMgr(e.file) Is Nothing Then
...
Else
...
End If

or

Dim ObjectLocal as Object = Me.axApplicationMgr.GetSequenceFileViewMgr(e.file)
If ObjectLocal Is Nothing Then
...
Else
...
End If

results in "Invalid pointer" exeception.
0 Kudos
Message 3 of 9
(4,014 Views)
I don't really know much about VB syntax, but I ran the code through a C# to VB translator and got the following:

Dim fileMgrObject As Object = Me.axApplicationMgr.GetSequenceFileViewMgr(sequenceFile)
If (Not (fileMgrObject) Is Nothing) Then
Dim fileMgr As SequenceFileViewMgr = CType(fileMgrObject,SequenceFileViewMgr)
Dim fileName As String = fileMgr.GetCaptionText(CaptionSources.CaptionSource_CurrentSequenceFile, true, "")
End If


It looks pretty much like what you have except for the parenthesis, but it might be worth trying.


BTW: the translator I used is at: http://www.carlosag.net/Tools/CodeTranslator/Default.aspx
0 Kudos
Message 4 of 9
(4,006 Views)
Thanks , James.

I think it is an ambiguous issue of ApplicationMgr. I have made some experiments on VB.NET and C# sample code, all of them issue an exception in the function axApplicationMgr_DisplaySequenceFile() if I try to invoke axApplicationMgr.GetSequenceFileViewMgr() before the first sequence file assignment. For example:

axApplicationMgr_DisplaySequenceFile()
{
axApplicationMgr.GetSequenceFileViewMgr(e.file)

axSequenceFileViewMgr.SequenceFile = e.file
}

But once a sequence file has been assigned to the SequencefileviewMgr, GetSequenceFileViewMgr() returns null or nothing instead of exception if I open another sequence file and there is no SequenceFileView displaying this sequence file.
0 Kudos
Message 5 of 9
(3,988 Views)
HI Cipher,

What is the exception that you are getting. I'll try to replicate this issue on my side and I'll submit a post on what I find.

SijinK
National Instruments
0 Kudos
Message 6 of 9
(3,964 Views)
Hi, SijinK:
My problem results from When I try to create a multi-window Operator interface, I follow the instructions of the TestStand Reference manual,
which indicates that I can invoke ApplicationMgr.GetSequenceFileViewMgr to determine whether a SequenceFileView Manager control is currently
displaying a sequence file. And I was trapped at the repeated "Invalid Pointer" exception.
My basic assumption is, GetSequenceFileViewMgr() should be able to return something successfully no matter if any sequence file has been opened,
because TestStand Help indicates that it will return either an Object reference or NULL. But it looks like I may misinterpret something.
So I try to keep the default Operator Interface application intact ,but add some codes for debug observation. And as in my previous reply,
I just add one line of code into the event DisplaySequenceFile()

Private Sub axApplicationMgr_DisplaySequenceFile(ByVal sender As Object, ByVal e As NationalInstruments.TestStand.Interop.UI.Ax......)

axApplicationMgr.GetSequenceFileViewMgr(e.file)

axSequenceFileViewMgr.SequenceFile = e.file

End Sub

And the result is, at the very beginnig of opening a sequence file, say A.Seq, GetSequenceFileViewMgr() issues "Invalid pointer" exception.
But if I ignore it, and execute the sequence file assignment, GetSequenceFileViewMgr() behaves normally when I open a sequence file next time.
i.e. if no SeguenceFileView Manager displays the selected sequence file, it return Nothing, else it returns a System.__ComObject which can be
re-casted to a desired type.

Any comments for this part?

Thanks.
0 Kudos
Message 7 of 9
(3,958 Views)
I'm not quite sure why this is happening, but I'll have to investigate a bit further. I would think that it shouldn't complain about being returned a null reference, but it looks like we are going to have to catch this exception.

Here is a workaround that should let you avoid the situation where the pointer is returned null.

Try
Dim fileMgrObject As Object = Me.AxApplicationMgr.GetSequenceFileViewMgr(e.file)
If (Not (fileMgrObject) Is Nothing) Then
Dim fileMgr As SequenceFileViewMgr = CType(fileMgrObject, SequenceFileViewMgr)
Dim fileName As String = fileMgr.GetCaptionText(CaptionSources.CaptionSource_CurrentSequenceFile, True, "")
End If

Catch exception As NullReferenceException
End Try

I'll be looking into this further to see if this is expected behavior. Hopefully this should work regardless.

Allen P
NI
0 Kudos
Message 8 of 9
(3,943 Views)
Cipher,

I tried your example and was able to reproduce the problem. The GetSequenceFileViewMgr and GetExecutionViewMgr methods of the ApplicationMgr do not work correctly when there is a SequenceFileViewMgr with a null file or an ExecutionViewMgr with a null execution, respectively.

The workaround is to either get the information these methods return another way, or to make sure your application never calls these methods when one of the corresponding view managers might have a null file or execution.

I apologize for the inconvenience and I appreciate your help in identifying the problem. We will fix this in a future release of TestStand.

- James
0 Kudos
Message 9 of 9
(3,934 Views)