lock Statement (C# Reference)
Console Error :
MissingMethodException: Method not found: ‘System.Threading.Monitor.Enter’.
Google Find Other Settings → Setted .net 2.0
Then Failure.
How do I use ?
Thanks you help.
lock Statement (C# Reference)
Console Error :
MissingMethodException: Method not found: ‘System.Threading.Monitor.Enter’.
Google Find Other Settings → Setted .net 2.0
Then Failure.
How do I use ?
Thanks you help.
Are you sure you need a lock statement? Pretty much all scripting-level stuff in Unity is happening cooperatively in a single thread. Unless you’re doing something really whacky with interrupts I’m not sure why you would need to use lock in a Unity context.
Reference external lib using C # lock
The code that uses the ‘lock’ command, is it in a separate project that then gets compiled into a dll that you then place in the unity project?
If so, that dll is probably compiled to target .Net 4.0 or the ilk. In .Net 4.0 the ‘lock’ statement is syntax sugar for the function ‘System.Threading.Monitor.Enter’… where as in previous versions it was not. This function does not exist in .Net 2.0 (which is the version of .Net/mono that unity targets). This results in this exception because the CIL in the dll can’t find the method in the actual .net/mono runtime when it actually runs.
Recompile your separate dll to target .Net 2.0.
Or better, if you have Visual Studio, and Visual Studio Tools for Unity, target ‘Unity 3.5 .net full Base Class Libraries’.