Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Does anyone know how to use vcnet in openning and closing session? The example from NI software only gives CS/VB.net and MFC. Is there anything in visual c++.net?

Does anyone know how to use vcnet in openning and closing session? The example from NI software only gives CS/VB.net and MFC. Is there anything in visual c++.net?
 
VB.net

mbSession =

CType(ResourceManager.GetLocalManager().Open(sr.ResourceName), MessageBasedSession)

mbSession.Dispose()

CS.net
 
mbSession = (MessageBasedSession)ResourceManager.GetLocalManager().Open(sr.ResourceName);
mbSession.Dispose();
 
VC.net
 
???
 
this is mine

rmSession->GetLocalManager();

(MessageBasedSession *) rmSession->Open("ASRL1::INSTR");

I don't have the closing session yet. mbSession->Dispose() does not exist on the MessageBasedSession or I maybe not routing my pointer

properly...

 

Need help...

0 Kudos
Message 1 of 6
(4,046 Views)

Hi spl,

National Instruments doesn't support managed C++ in .NET, only unmanaged C++.  You can use the Measurement Studio C# or VB.NET support to generate class libraries that are callable from managed C++ code.

0 Kudos
Message 2 of 6
(4,024 Views)

Try out this code snippet

NationalInstruments::VisaNS::ResourceManager *resourceManager;
resourceManager = NationalInstruments::VisaNS::ResourceManager::GetLocalManager();
mbSession = dynamic_cast<MessageBasedSession*>(resourceManager->Open("COM1"));
String * returnedString = mbSession->Query("*IDN?");
mbSession->Dispose();


For an indepth discussion on our support for managed C++, check out the following post

I hope this helps

Bilal Durrani
NI
0 Kudos
Message 3 of 6
(4,018 Views)
Thanks Michael for the reply.
 
It's pretty sad because now I would need to learn other language besides C++.
I have looked at C# and I have noticed that there are just minor differences
as compared with C++. Unfortunately, we don't have Visual C# here at work
to use.
 
I actually have already started looking into VB.net and use this to build my
drivers. I guess I would need to convert all my MFC drivers to VB.net...
 
Wow! I have a lot of work ahead of me...
 
Anyway, thanks again...
 
spl
0 Kudos
Message 4 of 6
(4,019 Views)

Before you start re-writing your application, I just wanted to elaborate a little more about our support for mananged C++ and make sure you know what options are available to you. Measurement Studio does not  provide examples, code snippets wizards or assistants for use with mananged C++, but that does not mean you cannot use the .NET libraries with managed C++. Managed C++ is a CLS compliant .NET language. The Measurement Studio .NET class libraries are Common Language Specification (CLS) compliant. This means that the .NET class libraries are usable from any CLS-compliant language, including managed C++.

As you can see from the link I posted, we limited our support  to C# and VB.NET, but that does not mean that managed C++ as a completely unsupported option. In fact, it is probably the best language of choice if you already have a large MFC code base that you cannot get away from.

So yes, while do not provide code snippets and examples and such for our .NET components in managed C++. it does not mean you cannot use the libraries from managed C++.

I hope this clears things up.


Bilal Durrani
NI
0 Kudos
Message 5 of 6
(4,009 Views)

Hi Bilal,

Thanks for the reply. I am actually working on still using my drivers to incorporate it in

vc.net framework.

I guess I just need to learn more about how to go about initializing my classes and

converting my variables to vc.net.

 

Thanks again...

spl

0 Kudos
Message 6 of 6
(4,003 Views)