Eliminate Interlocked CompareExchange
Hi,
I've found what I think is a "simpler" and more "general" solution for the ExecutionEngineException on events compiled with Visual Studio.
You can simply replace any call to the generic version of CompareExchange: call !!0 [mscorlib]System.Threading.Interlocked::CompareExchange<T>(!!0&, !!0, !!0)
With a call to the non-generic version: call object [mscorlib]System.Threading.Interlocked::CompareExchange(object&, object, object)
You can safely do the same for calls to Interlocked::Exchange. You'll maintain thread-safety, and (surprisingly) it works on all platforms (at least for trusted code).
Greatings.
Thanks for the tip! It looks like it is a better solution.
It may be months before I have time to implement this but I will make a note on the main page.
I'm sorry I can't help you with code. I'm patching my assemblies using ildasm/ilasm and some regexs. If I ever get around using Mono.Cecil I'll share.
Hey Jared!
We are just porting our Android/Windows Store project to iOS, so we need to compatlyze our framework again :)
Are there any plans to include this fix? With the current version we've got the problem that the call stacks don't match on exceptions, guess the pdb/mdb doesn't match the DLL anymore. With this fix it should be still compatible I guess.
I'm still wondering why there isn't any Unity way to do this, event handlers are quite common, aren't they?
Cheers Christian
I don't have time right now. There's a chance I may want/need this fix myself in 1-5 months :-/