Can not create a PIPoint properly

Discussion created by vkrejc on Sep 17, 2012
Latest reply on Sep 21, 2012 by hanyong



I have a pretty simple problem but I'm not able to resolve it :-(


I'm trying to create a PI Tag using C++ code below:



    if (spPISDK == NULL) 

     spServer = spPISDK->GetServers()->GetItem("BOHUSLAV-07028F");

     _bstr_t bstrPointName(_T("MyPointName"));
     _bstr_t bstrClassName(_T("base"));
     PointTypeConstants ptcPointType = pttypString;

     _NamedValuesPtr nvsTagAttr(__uuidof(NamedValues));
     _bstr_t bstrPointSource(_T("B"));
     _variant_t varPointSource(bstrPointSource);
     nvsTagAttr->Add("pointsource", &varPointSource);
     spServer->GetPIPoints()->Add(bstrPointName, bstrClassName, ptcPointType, nvsTagAttr);




Calling of the Add method is finished by throwing of the following exception:




Unhandled exception at 0x7c812aeb in ImportTags.exe: Microsoft C++ exception: _com_error at memory location 0x0012fc28..




The problem is evidently related to the returning of the PIPointPtr (since the value of _result is 0). Could anybody advice me what I'm doing wrong, please? I'm totally blind at this time and can not see the mistake :-)


One more information - I can see and view that tag using PI System Management Tools (so it is created) but it has a flag 'BAD' and its value is 'Pt Created'.