Editor hangs when .NET 4.6 is used

After switching a pretty big project to Unity 2017.1.0p3, I’ve tried the new .NET 4.6 runtime and, to my surprise, everything seemed to work just fine. That is, until I’ve tried closing the Editor. It completely locks up, so I have to use the Task Manager to kill it. The last line in the Editor.log file is

Cleanup mono

Reverting back to .NET 3.5 fixes the issue, so it’s clearly related to .NET 4.6 runtime somehow. I’ve tried to pinpoint the issue and sent a bug report with a repro project (case 944152). However, I’m really not sure what’s causing the hang. The code isn’t doing anything special. Any ideas for a workaround?

Thanks for reporting this issue. I’m communicated with our QA team about it, and we will investigate it.

I am affected by the same issue. Any suggestion Josh?

According to the note in the bug report, this issue was corrected in 2017.1.1p2. Please try that version of Unity. If you’re still seeing a hang, we would love another bug report. The cause might be different. Thanks!

I need 2017.2

I assume the bug is this one?

  • (958346) - Scripting: Fixed hang on exit in batch mode.

I don’t see that bug fix in the release notes of 2017.2 or any of it’s patch releases. I also don’t see it in 2017.2.1

Could you confirm which patch has it for 2017.2?

Actually, I was looking at case 944152. It looks like this was corrected in the first 2017.2 release. So if you are still seeing a hang in 2017.2, it might be something different.

@JoshPeterson Finally managed to open the bug. It took about 8 hours to upload the project, I have no idea why the bug reporting tool is so painfully slow.

Basically I am seeing the hang when I run the unit tests from command line in unity. Please take a look at 1010892

This bug happens with 2017.2 and 2017.3.1, It may happen with other versions. It only happens with .Net 4.6 runtime, but does not happen with .Net 3.5.

Thanks, we will investigate!

Could also be related to Unity Issue Tracker - .NET 4.6 Scripting runtime: Unity executable hangs when running tests in batchmode

That description matches the behavior I am seeing. Hopefully it is the same thing. I am glad to see it has been fixed in an upcoming version.