diff --git a/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/XmlWriterTraceListener.cs b/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/XmlWriterTraceListener.cs
index cf38c8d8539567..bf97f5fe8418c0 100644
--- a/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/XmlWriterTraceListener.cs
+++ b/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/XmlWriterTraceListener.cs
@@ -258,8 +258,15 @@ private void WriteEndHeader()
string? processName = s_processName;
if (processName is null)
{
- using Process process = Process.GetCurrentProcess();
- s_processName = processName = process.ProcessName;
+ try
+ {
+ using Process process = Process.GetCurrentProcess();
+ s_processName = processName = process.ProcessName;
+ }
+ catch (PlatformNotSupportedException) // Process isn't supported on Browser
+ {
+ s_processName = processName = string.Empty;
+ }
}
InternalWrite("\" />");
diff --git a/src/libraries/System.Diagnostics.TextWriterTraceListener/tests/XmlWriterTraceListenerTests.cs b/src/libraries/System.Diagnostics.TextWriterTraceListener/tests/XmlWriterTraceListenerTests.cs
index efcfb6f8a5638c..d71818e9fd097a 100644
--- a/src/libraries/System.Diagnostics.TextWriterTraceListener/tests/XmlWriterTraceListenerTests.cs
+++ b/src/libraries/System.Diagnostics.TextWriterTraceListener/tests/XmlWriterTraceListenerTests.cs
@@ -18,9 +18,16 @@ public class XmlWriterTraceListenerTests : FileCleanupTestBase
public XmlWriterTraceListenerTests()
{
- using (var process = Process.GetCurrentProcess())
+ try
{
- _processName = process.ProcessName;
+ using (var process = Process.GetCurrentProcess())
+ {
+ _processName = process.ProcessName;
+ }
+ }
+ catch (PlatformNotSupportedException) // Process isn't supported on Browser
+ {
+ _processName = string.Empty;
}
}
diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj
index 26793eb0334ba1..eebfd987fcaa9e 100644
--- a/src/libraries/tests.proj
+++ b/src/libraries/tests.proj
@@ -28,7 +28,6 @@
-