pyeska@tibco.com

Initialize PISDK in class constructor

Discussion created by pyeska@tibco.com on Jun 4, 2012
Latest reply on Jun 11, 2012 by andreas

Hi,

 

I would like to ask on behavior of  PI SDK.

 

I have class in C++ (Manager.cpp) which has private field IPISDKPtr. I initialize this field in constructor, like this:

 
spPISDK.CreateInstance(__uuidof(PISDK));

 

 

I have method for getting server by name. Method looks like this:

 
AbstractServer* Manager::createServer(std::string name)
{
    PIServer* result;
    ServerPtr spServer;
    MyLock* lock = new MyLock();
    if (name.empty())
        spServer = spPISDK->GetServers()->GetItem("Default"); 
    else 
        spServer = spPISDK->GetServers()->GetItem((_bstr_t) name.c_str());
    result = new PIServer(spServer);
    delete lock;
    return result;
}

 

 

When I run this code and try to call this metod, I receive exception (com_error at memory location 0x0271eba0.)

 

Notice: When I run this code directly inside constructor (after initialization), it works.

 

any Idea?

 

Thanks@

Outcomes