UWP: Exception "ClassFactory cannot supply requested class" for some specific target machines

0

I have the following code that in some sporadic target machines produce the following exception:

ClassFactory cannot supply requested class (Exception from HRESULT: 0x80040111)

This is the code that produces the exception:

WindowingEnvironment winEnv = WindowingEnvironment.FindAll(WindowingEnvironmentKind.Overlapped).FirstOrDefault();
if (winEnv == null)
    return;

IReadOnlyList<DisplayRegion> regions = winEnv.GetDisplayRegions();
List<string> monitorIds = new List<string>();
foreach (DisplayRegion region in regions)
{
    if (!region.IsVisible)
        continue;
    string monitorId = region.DisplayMonitorDeviceId;
    if (!monitorIds.Contains(monitorId))
    {
        monitorIds.Add(monitorId);
        Debug.WriteLine(region.WorkAreaSize.ToLTSize());
    }
}

This code works fine in all our development machines and in 99.9% of the user base, but in a few sporadic cases, it throws the above-mentioned exception. So, I guess it could be a problem of the target OS or some preferences of the user that would upset one of those APIs.

Please also note that the users experiencing this problem are running the latest Win 10 build.

Do you have any clue of which preferences/settings/etc. could affect this code?

Thank you!

c#
winapi
uwp
classnotfound
asked on Stack Overflow Jun 2, 2020 by Cristiano Ghersi • edited Jun 2, 2020 by Cristiano Ghersi

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0