Bug 10604 - MonoDevelop Error launching web browser when start xsp cause by MonoMac.AppKit.AppKitThreadAccessException
Summary: MonoDevelop Error launching web browser when start xsp cause by MonoMac.AppKi...
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: ASP.Net ()
Version: Trunk
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-02-23 09:57 UTC by Anton Heryanto
Modified: 2013-02-28 19:53 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Anton Heryanto 2013-02-23 09:57:29 UTC
MonoDevelop With ASP.NET Project (MVC4 in my case) 
throw error when start debugging where monodevelop launch xsp4 and after that launch browser

but  MonoMac.AppKit.AppKitThreadAccessException are thrown when launch browser

MonoMac.AppKit.AppKitThreadAccessException: AppKit Consistency error: you are calling a method that can only be invoked from the UI thread.
  at MonoMac.AppKit.NSApplication.EnsureUIThread () [0x00000] in <filename unknown>:0 
  at MonoMac.AppKit.NSWorkspace.get_SharedWorkspace () [0x00000] in <filename unknown>:0 
  at MonoDevelop.MacIntegration.MacPlatformService.OpenUrl (System.String url) [0x00000] in /Users/anton/Repository/monodevelop/main/src/addins/MacPlatform/MacPlatform.cs:141 
  at MonoDevelop.MacIntegration.MacPlatformService.ShowUrl (System.String url) [0x00000] in /Users/anton/Repository/monodevelop/main/src/addins/MacPlatform/MacPlatform.cs:136 
  at MonoDevelop.Ide.DesktopService.ShowUrl (System.String url) [0x00000] in /Users/anton/Repository/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs:94 
  at MonoDevelop.AspNet.Gui.BrowserLauncher.LaunchDefaultBrowser (System.String url) [0x00000] in /Users/anton/Repository/monodevelop/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Gui/BrowserLauncher.cs:42 

possible cause of it are 
by Add ThreadSafe attribute to MonoMac
merge url: https://github.com/mono/monomac/commit/2a986b2286adae0695cb26722483ca9b57e0172e
as shown by exception message which thrown by AppKitThreadAccessException
Comment 1 Aaron Oneal 2013-02-23 12:21:02 UTC
The shared instance of NSWorkspace should be fixed to be decorated with the ThreadSafe attribute, but the only member on NSWorkspace in the Apple docs which is explicitly stated to be thread safe is "runningApplications".

MacPlatformService should perhaps be updated to access NSWorkspace from the main thread for this operation.
Comment 2 Mikayla Hutchinson [MSFT] 2013-02-23 17:01:07 UTC
Or we could p/invoke launch services.
Comment 3 Anton Heryanto 2013-02-28 19:53:44 UTC
i have check the monodevelop latest commit https://github.com/mono/monodevelop/commit/8ad3dc9fcfe79fdb51ffc4f4eda14ff0fab25ac8 which fix the problem. thanks guys for awesome support :D