System.Exception AMDeviceNotificationSubscribe returned ...

Important

This issue has been resolved in recent versions of Xamarin. However, if the issue occurs on the latest version of the software, please file a new bug with your full versioning information and full build log output.

Fix

  1. Kill the usbmuxd process so that the system will restart it:

    sudo killall -QUIT usbmuxd
    
  2. If that doesn't solve the problem, reboot the Mac.

Error message

Exception: Exception type: System.Exception
AMDeviceNotificationSubscribe returned: 3892314211
  at Xamarin.MacDev.IPhoneDeviceManager.SubscribeToNotifications () [0x00000] in <filename unknown="">:0
  at Xamarin.MacDev.IPhoneDeviceManager.StartWatching (Boolean useOwnRunloop) [0x00000] in <filename unknown="">:0
  at Mtb.Server.DeviceListener.Start () [0x00000] in <filename unknown="">:0
  at Mtb.Application.MainClass.RunDeviceListener () [0x00000] in <filename unknown="">:0
  at Mtb.Application.MainClass.Main (System.String[] args) [0x00000] in <filename unknown="">:0

This message can appear in an error dialog when you first start Visual Studio for Mac, or in the mtbserver.log file in the Xamarin.iOS Build Host app (Xamarin.iOS Build Host > View Build Host Log).

Note that this is an uncommon problem. If Visual Studio is having trouble connecting to the Mac build host, there are other errors that are more likely to appear in the mtbserver.log file.

Errors in system.log

In some cases the following two error messages might also appear repeatedly in /var/log/system.log:

17:17:11.369 usbmuxd[55040]: dnssd_clientstub ConnectToServer: socket failed 24 Too many open files
17:17:11.369 com.apple.usbmuxd[55040]: _BrowseReplyReceivedCallback Error doing DNSServiceResolve(): -65539

Additional information

One guess at the root cause of the error is that the OS X system services responsible for reporting iOS device and simulator information can in rare cases enter an unexpected state. Xamarin cannot interact properly with the system services in this state. Rebooting the computer restarts the system services and solves the problem.

Based on the errors from system.log it appears that this problem might be related to Bonjour (mDNSResponder). Changing between different WiFi networks seems to increase the chances of hitting the problem.