NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

ts.SequenceContext

Solved!
Go to solution

Hi,

 

I'm creating a .NET assembly to display a dialog to allow a user to edit and select properties in a new step type, for that, I have a simple class that exposes a function to display a dialog, it works fine and the dialog is displayed on the screen and everithing works perfectly... but i need to access the step properties and some other TS objects, for that, I added the argument "TS::SequenceContext^ context",  as in the next code, it compiles fine, no errors.

 

public ref class TSStepType {

      public: void ShowSendMessageConfig(TS::SequenceContext^ context) {
            SendMessageConfigForm^ dialog = gcnew SendMessageConfigForm();
            dialog->Show();
      }
};

 

However, when I try to call this step in the edit substep, I get an error for this member..

 

Use Existing Object(SCDTSStepTypes.TSStepType).ShowSendMessageConfig {Requires Unloadable Type}()

 

If I do not have this argument, it works fine and the error does not shows, I have tried using static method and trying to declare a property in the object and it gives me the same error.

 

I'm using Visual Studio 2013, developping my assembly with Visual C++ and I have the 2013 version of TestStand.

 

Any suggestion?

0 Kudos
Message 1 of 9
(4,987 Views)

FelipeArias,

 

Could you tell me which interface are you using?  And which adapter are you using?  I have an assumption, but want to know for sure before going further.

Wayne T. | Application Engineer | National Instruments
0 Kudos
Message 2 of 9
(4,949 Views)
Solution
Accepted by topic author FelipeArias

I see two problems with your code:

 

1) TS::SequenceContext is not the right class. That is an unmanaged class you got by doing #import on the typelibrary or including one of TestStand's headers which does so. You need to add a .NET reference to the assembly named TestStand 2013 API Primary Interop Assembly (it's also in the GAC with this name: NationalInstruments.TestStand.Interop.API.dll, but it should show up in the Visual Studio add references dialog with the name "TestStand 2013 API Primary Interop Assembly"). Once you have added that you can either add a "using" declaration for the TestStand namespace or use the full scoped typename as follows:

 

NationalInstruments::TestStand::Interop::API::SequenceContext

 

2) dialog->Show() is not the right way to show a dialog modally (where it will wait until the dialog is dismissed). You need to do something more like the following instead:

 

SendMessageConfigForm^ dialog = gcnew SendMessageConfigForm();

dialog->ShowDialog(); // displays the dialog modally

dialog->Dispose(); // You should call dispose on dialog classes when you are done with them.

 

Hope this helps,

-Doug

 

P.S. - Forum is turning the ':' next to the 'S' character into a smilely. Please use ':' and 'S' whereever you see the smiley.

0 Kudos
Message 3 of 9
(4,944 Views)

Thanks for your response...

 

I'm trying to use this control:

C:\Program Files (x86)\National Instruments\TestStand 2013\BIN\teapi.dll

Version: 1.0

 

I my steps I'm using the .NET adapter. The interface is TS.SequenceContext, as imported by Visual Studio.

 

I was suggested to try the .NET libraries provided by TestStand, and they work fine, but using the COM interop should work also but that gives me the error I have..

 

Thanks

0 Kudos
Message 4 of 9
(4,918 Views)

@FelipeArias wrote:

Thanks for your response...

 

I'm trying to use this control:

C:\Program Files (x86)\National Instruments\TestStand 2013\BIN\teapi.dll

Version: 1.0

 

I my steps I'm using the .NET adapter. The interface is TS.SequenceContext, as imported by Visual Studio.

 

I was suggested to try the .NET libraries provided by TestStand, and they work fine, but using the COM interop should work also but that gives me the error I have..

 

Thanks


 

How did you get TS::SequenceContext? Maybe I'm misunderstanding where you got it from.

 

The .NET adapter only supports .NET data types. If you used the unmanaged C++ COM wrappers in your prototype you are creating a mixed prototype with unmanaged types in it. That is not supported. Why would you not use the managed version of SequenceContext like I suggested in my previous post? TestStand will automatically convert such a context to and from the .NET versions of the runtime callable wrapper when you use the .NET adapter, so there really is no need to ever use the TS::SequenceContext type in a prototype you want to call from the .NET adapter.

 

-Doug

0 Kudos
Message 5 of 9
(4,914 Views)

If you are dynamically generating a managed COM interop from our typelibraries, the problem might be that you are not including the generated interop assembly with your assembly. Thus the "Unloadable types" error. I might have misunderstood what you are doing, I thought you were using the unmanaged TS::SequenceContext class that can get generated if you used #import.

 

-Doug

0 Kudos
Message 6 of 9
(4,906 Views)

Hi Doug,

 

I'm now doing what you say, and it works now, no problem, thanks, I was just wondering why the COM interop was not working as I was expecting, all the import work is done by Visual Studio when I add the COM reference, (that gives me the TS namespace), so I was thinking that this should also work, but now you explained that to me the problem, I will use your solution.

 

Using the NET api as you mention helps and I have not everything working.

 

Thanks!

0 Kudos
Message 7 of 9
(4,905 Views)

@FelipeArias wrote:

Hi Doug,

 

I'm now doing what you say, and it works now, no problem, thanks, I was just wondering why the COM interop was not working as I was expecting, all the import work is done by Visual Studio when I add the COM reference, (that gives me the TS namespace), so I was thinking that this should also work, but now you explained that to me the problem, I will use your solution.

 

Using the NET api as you mention helps and I have not everything working.

 

Thanks!


I think I was misunderstanding where you were getting TS::SequenceContext from (sorry about that). Now I think I understand. I think you had Visual Studio generate the interop dynamically. That should work, but you will then have to make sure you include that generated interop (or embed it) in order for the .NET adapter to find the types. I highly recommend you use the interop we ship with TestStand and install to the GAC instead though since we've processed it a bit to make it nicer than the auto-generated one.

 

-Doug

0 Kudos
Message 8 of 9
(4,899 Views)

Thanks!

 

Yes, I will use it... it is is easier.

 

Just a spell fix.... My text that says "Using the NET api as you mention helps and I have not everything working" should say "Using the NET api as you mention helps and I have now everything working"

 

Thanks

0 Kudos
Message 9 of 9
(4,894 Views)