Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an application that tries to connect to EWS server and get / refresh login token.
The code is below:
C#
var pcaOptions = new PublicClientApplicationOptions
{
    ClientId = _configParams.ClientId,
    TenantId = _configParams.TenantId
};
var pca = PublicClientApplicationBuilder.CreateWithApplicationOptions(pcaOptions).Build();
TokenCacheHelper.EnableSerialization(pca.UserTokenCache, _configParams.ApplicationName, _configParams.Address);
AddToLog($"Getting accounts...");
Task<IEnumerable<IAccount>> t1 = Task.Run(() => pca.GetAccountsAsync());
AddToLog($"Getting accounts task created...");
try
{
    if (!t1.Wait(WAIT_LOGIN_TASK_SEC))
        return null;
}
catch (Exception ex)
{
    return null;
}

The problem: command
t1.Wait(WAIT_LOGIN_TASK_SEC)
causes
1. Exception with message "One or more errors occurred." and inner exception "Key not valid for use in specified state"
2. Warning in Windows applications log:
PercProc Event 2002 : Unable to open the job object \BaseNamedObjects\WmiProviderSubSystemHostJob for query access. The calling process may not have permission to open this job. The first four bytes (DWORD) of the Data section contains the status code.

This code worked fine until it was run on a new Virtual Machine.
I compared Windows versions
Working on: Windows 10 Pro, Version 21H2, OS Build 19044.1889
Not Working on : Windows 10 Pro, Version 22H2, OS Build 19045.4046

Please, advise, how to fix the problem.
Thanks.

What I have tried:

Checking Privileges (the application runs under administrator account),
Checking Firewall (the corresponding rules were added),
Checking registry (advise from Internet),
Rebuilding performance counters (advise from Internet),
Running checkdisk, SFC and DISM (advise from Internet)
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900