Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Error to use Dispose API of NI-VISA in C++

Solved!
Go to solution

Hi,

I installed NI-VISA v18.00. and tried to create power supply control program in C++.

Refer to example code from NI-VISA  "Examples\.NET\17.5\SimpleReadWrite"

I could send USB command to control Keithley power-supply 2230G  properly. 

but when I would like to close the connected session. the compiler show the error message as below :

error C2039: 'Dispose' : is not a member of 'NationalInstruments::Visa::MessageBasedSession'

Does anyone have idea about this?  Thanks

Operation System : Win10 x64 VS2013

//my sample code

MessageBasedSession^ mbSession;

NationalInstruments::Visa::ResourceManager^ rmSession = gcnew ResourceManager();

 

strResource = rmSession->Find("USB?*0x2230?*INSTR");
for each (System::String^ strCom in strResource)
{
resourceID = strCom;
}
try {
     mbSession = (NationalInstruments::Visa::MessageBasedSession^)rmSession->Open(resourceID);

}
catch (...) {
}
try {
     mbSession->RawIO->Write("OUTP ON");
     Sleep(500);
}
catch (...) {
}
    Sleep(1000); //wait for Power supply stable
    mbSession->Dispose();  //compile error

 

0 Kudos
Message 1 of 3
(3,805 Views)

Hi CharlesL,

 

You could replace the:

mbSession->Dispose();

with

delete mbSession;

 

Thanks and Regards,

 

Alysa

0 Kudos
Message 2 of 3
(3,773 Views)
Solution
Accepted by topic author CharlesL

@AlysaOng  已寫:

Hi CharlesL,

 

You could replace the:

mbSession->Dispose();

with

delete mbSession;

 

Thanks and Regards,

 

Alysa



@AlysaOng  已寫:

Hi CharlesL,

 

You could replace the:

mbSession->Dispose();

with

delete mbSession;

 

Thanks and Regards,

 

Alysa


it's working.

Thanks for your supporting.

Message 3 of 3
(3,770 Views)