views:

124

answers:

1

I've got a code like this:

Some of our clients receiving "System.ArgumentNullException in System.Threading.Monitor.Enter" in the following code block:

Public Class CheckStuff

   Private Shared SLock As New Object

   Public Sub GetIt()
          Synclock SLock
             DoSomething()
          End Synclock       
   End Sub
End Class

How can this be possible? Considering the SLock is shared, never touched from anywhere else?

+1  A: 

My guess is that you've oversimplified your sample code - it must be touched from something else to make it Nothing. Or, your locking method is called before CheckStuff has finished initializing. A stack trace would be helpful.

Jon Skeet
That's the problem, I've just look for all references and there is none. Also this never happened in our development or testing environments although reported from 2 clients.
dr. evil
Do you have stack traces?
Jon Skeet
System.Threading.Monitor.Enter(obj As Object) .. ThreadAcc.exe: N 00000 .. GetIt() ... called from GUI
dr. evil
@dr. evil: I'm afraid I have no idea what that was meant to tell me... please edit your question to give more information instead. (And then read through what you've written, pretending you're someone who doesn't already know what you're trying to say.)
Jon Skeet