Skip to content

Commit ce6c452

Browse files
authored
Merge pull request #5585 from Particular/principal-fix-72
Thread.CurrentPrincipal will throw PlatformNotSupportedException on .NET Core 3.x
2 parents 14a7617 + 37939a8 commit ce6c452

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/NServiceBus.Core/StartableEndpoint.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
namespace NServiceBus
22
{
33
using System;
4+
#if NETSTANDARD
5+
using System.Runtime.InteropServices;
6+
#endif
47
using System.Security.Principal;
58
using System.Threading.Tasks;
69
using Settings;
@@ -30,8 +33,14 @@ public async Task<IEndpointInstance> Start()
3033

3134
await transportInfrastructure.Start().ConfigureAwait(false);
3235

36+
#if NETSTANDARD
37+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
38+
{
39+
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
40+
}
41+
#else
3342
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
34-
43+
#endif
3544
await receiveComponent.Initialize(containerComponent, recoverabilityComponent).ConfigureAwait(false);
3645

3746
await featureComponent.Start(messageSession).ConfigureAwait(false);

0 commit comments

Comments
 (0)