Objects that can be accessed across application domain boundaries are said to have weak identity. This means that these objects can be considered shared resources outside of the domain, which can be lead to them being accessed or modified by multiple threads or concurrent parts of a program, outside of the domain.
A thread acquiring a lock on such an object runs the risk of being blocked by another thread in a different application domain, leading to poor performance and potentially thread starvation and deadlocks.
Types with weak identity are:
Public Class Sample
Private ReadOnly myLock As New StackOverflowException
Public Sub Go()
SyncLock myLock ' Noncompliant
' ...
End SyncLock
End Sub
End Class
Public Class Sample
Private ReadOnly myLock As New Object
Public Sub Go()
SyncLock myLock
' ...
End SyncLock
End Sub
End Class