Skip to content

Commit 0463f86

Browse files
Catch DllNotFoundException if P/Invoke into EnumerateTraceGuidsEx fails.
1 parent d6d76cb commit 0463f86

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

mcs/class/referencesource/mscorlib/system/diagnostics/eventing/eventprovider.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,9 +511,17 @@ private unsafe void GetSessionInfo(Action<int, long> action)
511511

512512
fixed (Guid* provider = &m_providerId)
513513
{
514-
hr = UnsafeNativeMethods.ManifestEtw.EnumerateTraceGuidsEx(UnsafeNativeMethods.ManifestEtw.TRACE_QUERY_INFO_CLASS.TraceGuidQueryInfo,
515-
provider, sizeof(Guid), buffer, buffSize, ref buffSize);
516-
}
514+
try
515+
{
516+
hr = UnsafeNativeMethods.ManifestEtw.EnumerateTraceGuidsEx(UnsafeNativeMethods.ManifestEtw.TRACE_QUERY_INFO_CLASS.TraceGuidQueryInfo,
517+
provider, sizeof(Guid), buffer, buffSize, ref buffSize);
518+
}
519+
catch (DllNotFoundException)
520+
{
521+
// This API isn't available on UWP prior to Windows SDK 16299
522+
return;
523+
}
524+
}
517525
if (hr == 0)
518526
break;
519527
if (hr != 122 /* ERROR_INSUFFICIENT_BUFFER */)

0 commit comments

Comments
 (0)