Skip to content

Commit

Permalink
Fixes dotnet#3715 - Add currentUserSID to GetApplicationInstanceID fo…
Browse files Browse the repository at this point in the history
…r use in TryCreatePipeServer to avoid system wide blocking. Used in conjunction with PipeOptions.CurrentUserOnly
  • Loading branch information
elachlan committed Apr 23, 2024
1 parent 48a3d7c commit 22668d1
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1006,28 +1006,26 @@ Namespace Microsoft.VisualBasic.ApplicationServices

''' <summary>
''' Generates the name for the remote singleton that we use to channel multiple instances
''' to the same application model thread.
''' to the same application model thread for the current user.
''' </summary>
''' <returns>A string unique to the application that should be the same for versions of
''' the application that have the same Major and Minor Version Number
''' </returns>
''' <remarks>If GUID Attribute does not exist fall back to unique ModuleVersionId</remarks>
Private Shared Function GetApplicationInstanceID(ByVal Entry As Assembly) As String
Dim guidAttribute As GuidAttribute = Entry.GetCustomAttribute(Of GuidAttribute)()
Dim currentUserSID As String = Principal.WindowsIdentity.GetCurrent().User.Value

Dim guidAttrib As GuidAttribute = Entry.GetCustomAttribute(Of GuidAttribute)()

If guidAttrib IsNot Nothing Then

If guidAttribute IsNot Nothing Then
Dim version As Version = Entry.GetName.Version

If version IsNot Nothing Then
Return $"{guidAttrib.Value}{version.Major}.{version.Minor}"
Return $"{guidAttribute.Value}{version.Major}.{version.Minor}-{currentUserSID}"
Else
Return guidAttrib.Value
Return $"{guidAttribute.Value}-{currentUserSID}"
End If
End If

Return Entry.ManifestModule.ModuleVersionId.ToString()
Return $"{Entry.ManifestModule.ModuleVersionId}-{currentUserSID}"
End Function
End Class
End Namespace

0 comments on commit 22668d1

Please sign in to comment.