include::../why-dotnet.adoc[]

== How to fix it

=== Code examples

==== Noncompliant code example

[source,vbnet,diff-id=1,diff-type=noncompliant]
----
Public Class Sample
    Private ReadOnly myLock As New StackOverflowException

    Public Sub Go()
        SyncLock myLock ' Noncompliant
        ' ...
        End SyncLock
    End Sub
End Class
----

==== Compliant solution

[source,vbnet,diff-id=1,diff-type=compliant]
----
Public Class Sample
    Private ReadOnly myLock As New Object

    Public Sub Go()
        SyncLock myLock
        ' ...
        End SyncLock
    End Sub
End Class
----

include::../rspecator.adoc[]

include::../resources-dotnet.adoc[]