Rider suddenly having trouble connecting to unity for debug and unit test sessions

I’ve recently been experiencing a problem where I have to constantly click back and forth between unity and rider when debugging or running unit tests. for example

Click run all unit tests in rider… It stalls on pending… I click back on unity, nothing happens, click back on rider, nothing happens, then click on unity, and a little popup appears briefly that I can’t read, but looks like the code refreshing popup, then back to rider, and suddenly all the tests run.

Another possibly related issue, tests in unity take milliseconds to complete, whereas rider (once it finally gets going) takes around 20-30 seconds. It seems to have trouble moving between the different assemblies or something.

Rider’s code coverage isn’t working at all, and crashes unity every time. Everything seemed to be working perfectly a month or two ago but I’ve since updated unity and rider a couple times.

Anyone know of any way to fix this issue which seems to be related to

Rider 2021.3.3, Unity 2021.2.14f1

If your project is not NDA you can privately submit it to https://youtrack.jetbrains.com/issues/RIDER
Or you may try if the problem reproduces with some open-source project on your machine.

Not personally using rider, but I would suggest checking that you have the latest Rider-Unity package installed. If you are on the latest, perhaps try going down one version to see if you have a bug from the current version.

I submitted a bug report to Rider with logs as the support person suggested, haven’t heard back. #3889544

Yes rider plugin is up to date

1 Like

I have been experiencing this way more often (within the last few weeks/months, ever since DOTS 0.50 came out and I had to move my projects back to 2020.x, instead of 2021.x) than I ever have in the past. It is constant. I have Alt+R in Rider mapped to refreshing Unity to compile and now it only works maybe 1 out of every 4-5 times that I try. I have to tab back to Unity, refresh there, then only sometimes when I go back to Rider does it show a connection again back to Unity. Otherwise it just thinks its disconnected / Unity is closed. Yet, most other things work as expected, it’s just super annoying.

I am using Rider 2023.x edition and have been having issues attaching the unity editor.

The only solution that worked for me was to

  1. Make sure you have the latest Rider Editor package in package manager
  2. Close unity editor and rider editor
  3. Navigate to the unity project and remove the *.csproj files (found on the project root folder)
  4. Reopen unity and proceed as normal with debugging with rider

I found deleting the *.csproj files caused unity to regenerate them and it works

Please note that if you go to Preferences/External Tools and click regenerate files that it still does not work. For some reason it does not properly regenerate the csproj files.

8 Likes

@GXMark would you please report an issue with Help->Report a Bug and agree to attach logs? We are definitely interested to look into it. Thank you!

Done.

Hi - happy to have come across this thread. I was having the same issue with Unity 2023.1.0b16. Unity would crash every time I tried to run the game when the debugger attached. I deleted my .csproj files as GXMark suggested and now it’s working. The specific error I was getting in the crash dump was: “The thread tried to read from or write to a virtual address for which it does not have the appropriate access

Could you please send me the link directly or share it here? I can’t find it unfortunately.

Rider suddenly having trouble connecting to unity for debug and unit test sessions : RIDER-93573 (jetbrains.com)

1 Like

To anyone still having the issue, this solution worked with Unity 2023.2.14 and Rider 2023.3.3

Thanks @GXMark for the solution.

This worked for me as well! Thank you!