问题
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:
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.
回答2:
Maybe similar problem - System.ArgumentNullException in ResourceManager.GetString internals.
来源:https://stackoverflow.com/questions/1655182/system-argumentnullexception-in-system-threading-monitor-enter