Skip to content

Commit 745bb8f

Browse files
committed
Use Environment.ProcessId in .NET 5.
1 parent 8f7f742 commit 745bb8f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/MySqlConnector/Core/ServerSession.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1554,9 +1554,14 @@ private byte[] CreateConnectionAttributes(string programName)
15541554
catch (PlatformNotSupportedException)
15551555
{
15561556
}
1557+
#if NET45 || NET461 || NET471 || NETSTANDARD1_3 || NETSTANDARD2_0 || NETSTANDARD2_1 || NETCOREAPP2_1 || NETCOREAPP3_1
15571558
using var process = Process.GetCurrentProcess();
1559+
var processId = process.Id;
1560+
#else
1561+
var processId = Environment.ProcessId;
1562+
#endif
15581563
attributesWriter.WriteLengthEncodedString("_pid");
1559-
attributesWriter.WriteLengthEncodedString(process.Id.ToString(CultureInfo.InvariantCulture));
1564+
attributesWriter.WriteLengthEncodedString(processId.ToString(CultureInfo.InvariantCulture));
15601565
if (programName.Length != 0)
15611566
{
15621567
attributesWriter.WriteLengthEncodedString("program_name");

0 commit comments

Comments
 (0)