HRESULT = 0x80131902 when using Ischeduler.connect

3

I'm trying to connect to a windows HPC using C++ with code I lifted from https://msdn.microsoft.com/en-us/library/cc853425(v=vs.85).aspx

on a test project all worked well, but when i tried to copy paste to my main project i started getting 0x80131902 from the pScheduler->Connect line.

I tried to match all the project settings, commented out all the code but this and still the same error. It's getting to the point where I'm contemplating rebuilding my main project from scratch but it's a big and convoluted mess which I'd rather avoid if at all possible.

Has anyone encountered this issue?

// 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();
}
c++
windows
hpc
hresult
asked on Stack Overflow Apr 28, 2015 by Eyal • edited Apr 28, 2015 by Paul R

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0