I don't know if this question is still relevant, but I happened to get the exact same error about a week ago. I wasted so much time on it, definitely too much, and so I want to share what I found out, so that others won't make my mistakes. After all, it's literally the first result when you google error message "[mono] debugger-agent: Unable to connect to" and I haven't found any other site mentioning this problem. So...
If you're using a rather unusual IP 10.0.2.2 as the IP of a host with Android emulator, I think it's safe to assume you're doing the same thing that I'm doing - that is: run Windows inside of Qubes VM and Android Emulator on a host OS, presumably Linux (like me), probably because running an emulator inside of a VM is a bad thing (and also it's doesn't really work - at least for me). What I found is that connecting to the Android emulator on the host OS is quite easy - you just need to type adb connect 10.0.2.2
in CMD in Windows (guest OS) and the running Android emulator will show up when you type adb devices
.
(Also, just a quick sidenote tip which would also save me a lot of time - if when you type the aforementioned command you get an "unauthorized device" message try opening an Android emulator without Play services - it solved the problem for me).
Now that's when the problem occurs. When I start debugging in Visual Studio everything works well, the app is built successfully and is starting on the device emulator, but then, after literally a second being opened, it crashes - Android emulator comes back to the home screen and in Visual Studio the last (and only) error message I get is [mono] debugger-agent: Unable to connect to 10.0.2.2:[random port here]
. To be honest it is quite frustrating, because it doesn't tell you why it can't connect to the device. I tried turning the output verbosity to maximum everywhere it's possible, but it still just says that it can't connect and that's all.
To be clear - I can open the app - if I press "Start without debugging" in Visual Studio the app starts on the Android emulator. I just can't debug it - and that's quite important. Also, without debugger the XAML Hot Reload feature doesn't work and that's a quite useful feature - at least in some cases.
Anyway, after being frustrated with it for a long time I tried doing things that - as I thought - shouldn't work. And one of those things obviously did work.
The thing that solved everything for me is just restarting the Android emulator as root. To do that you just need to write in CMD in Windows (the guest OS):
adb -s 10.0.2.2:5555 root
The IP is that of the host with Android emulator - in your case the IP address should be the same.
The only thing that's left is that now in Visual Studio a new Android device shows up called "unknown Android SDK built for x86 ([version of Android SDK])". That's the device that you should now connect to and debug on. Don't know why's that a case, but it works for me.
As I said - I don't know if what I wrote applies to you, but I wrote it down anyway as a resource for other. I hope I helped at least someone.