使用Ischeduler.connect时HRESULT = 0x80131902

时间:2015-04-28 13:30:15

标签: c++ windows hpc hresult

我正在尝试使用C ++连接到Windows HPC,代码我从https://msdn.microsoft.com/en-us/library/cc853425(v=vs.85).aspx取消

在一个测试项目上都运行良好,但是当我尝试将粘贴复制到我的主项目时,我开始从pScheduler-> Connect行获得0x80131902。

我尝试匹配所有项目设置,注释掉所有代码,但这仍然是同样的错误。 它已经到了我正在考虑从头开始重建我的主要项目的地步,但这是一个大而且复杂的混乱,如果可能的话我宁愿避免。

有没有人遇到过这个问题?

// The Microsoft.Hpc.Scheduler.tlb and Microsoft.Hpc.Scheduler.Properties.tlb type
// libraries are included in the Microsoft HPC Pack 2008 SDK. The type libraries are
// located in the "Microsoft HPC Pack 2008 SDK\Lib\i386" or \amd64 folder. Include the rename 
// attributes to avoid name collisions.

#include <windows.h>
#include <stdio.h>

#import <C:\Program Files\Microsoft HPC Pack 2008 R2\Bin\Microsoft.Hpc.Scheduler.tlb> named_guids no_namespace raw_interfaces_only \
rename("SetEnvironmentVariable","SetHpcEnvironmentVariable") \
rename("AddJob", "AddHpcJob")
#import <C:\Program Files\Microsoft HPC Pack 2008 R2\Bin\Microsoft.Hpc.Scheduler.Properties.tlb> named_guids no_namespace raw_interfaces_only 

void connectToHPC(const char* ServerName)
{
    HRESULT hr = S_OK;
    IScheduler* pScheduler = NULL;
    ISchedulerCollection* pJobs = NULL;
    IIntCollection* pJobIds = NULL;
    IFilterCollection* pFilters = NULL;
    VARIANT var;
    long count = 0;
    long jobId = 0;
    long* retVal = nullptr;

    CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);

    // Get an instance of the Scheduler object. 
    hr = CoCreateInstance( __uuidof(Scheduler), // CLSID_Scheduler, 
                       NULL,
                       CLSCTX_INPROC_SERVER,
                       __uuidof(IScheduler), // IID_IScheduler, 
                       reinterpret_cast<void **> (&pScheduler) );

     if (FAILED(hr))
    {
        wprintf(L"CoCreateInstance(IScheduler) failed with 0x%x.\n", hr);
        goto cleanup;
    }

    hr = pScheduler->Connect(_bstr_t(ServerName));
    if (FAILED(hr))
    {
        wprintf(L"Unable to connect to cluster %s. Failed with 0x%x.\n", ServerName, hr);
        goto cleanup;
    }
cleanup:
    // Before exiting, release your instance of IScheduler.
    if (pScheduler)
        pScheduler->Release();

    CoUninitialize();
}

0 个答案:

没有答案