Skip to content

Commit

Permalink
Fixes #1198
Browse files Browse the repository at this point in the history
[Watson] clr20r3: CLR_EXCEPTION_System.Collections.Generic.KeyNotFoundException_80131577_PresentationCore.dll!MS.Internal.DpiUtil+DpiAwarenessScope..ctor
--

When a caller passes in `dpiAwarenessContextValue==Invalid`, `new DpiAwarenessContextHandle(dpiAwarenssContextValue)` throws `KeyNotFoundException`.

This happens because we do not have a pre-created pseudo-_HANDLE_  corresponding to `Invalid` in our internal map of pseudo-handles in `DpiAwarenessContextHandle.WellKnownContextValues`. Such a pseudo-handle cannot be created either.

When `dpiAwarenessContextValue=Invalid` is passed, the correct behavior is to treat it as a no-op and simply `return`. The corresponding `Dispose()` will also run benignly and the caller will get the correct behavior - which is that no changes will be made to the thread-state.
  • Loading branch information
vatsan-madhavan committed Aug 2, 2019
1 parent 0635105 commit 208cec7
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ private DpiAwarenessScope(
bool updateIfWindowIsSystemAwareOrUnaware,
IntPtr hWnd)
{
if (dpiAwarenessContextValue == DpiAwarenessContextValue.Invalid)
{
return;
}

if (!OperationSupported)
{
return;
Expand Down

0 comments on commit 208cec7

Please sign in to comment.