Bug 3015 - Exception thrown while adding image and Xcode open
Summary: Exception thrown while adding image and Xcode open
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: iOS add-in ()
Version: 2.8.5
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Alan McGovern
URL:
Depends on:
Blocks:
 
Reported: 2012-01-23 11:23 UTC by Jackson Harper
Modified: 2013-04-02 15:36 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 Jackson Harper 2012-01-23 11:23:50 UTC
Twice this morning while adding a new image to my project while Xcode is open I've gotten this exception:

(Does not happen every time though)


System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object
  at MonoDevelop.MacDev.XcodeSyncing.XcodeProjectTracker.CheckFileChanges (MonoDevelop.Projects.ProjectFileEventArgs e) [0x00101] in /private/tmp/source/monodevelop/main/src/addins/MonoDevelop.MacDev/XcodeSyncing/XcodeProjectTracker.cs:271 
  at MonoDevelop.MacDev.XcodeSyncing.XcodeProjectTracker.FileAddedToProject (System.Object sender, MonoDevelop.Projects.ProjectFileEventArgs e) [0x00000] in /private/tmp/source/monodevelop/main/src/addins/MonoDevelop.MacDev/XcodeSyncing/XcodeProjectTracker.cs:224 
  at (wrapper delegate-invoke) <Module>:invoke_void__this___object_ProjectFileEventArgs (object,MonoDevelop.Projects.ProjectFileEventArgs)
  at MonoDevelop.Projects.Project.OnFileAddedToProject (MonoDevelop.Projects.ProjectFileEventArgs e) [0x00012] in /private/tmp/source/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs:947 
  at MonoDevelop.IPhone.IPhoneProject.OnFileAddedToProject (MonoDevelop.Projects.ProjectFileEventArgs args) [0x00068] in /private/tmp/source/md-addins/MonoDevelop.IPhone/MonoDevelop.IPhone/Project/IPhoneProject.cs:520 
  at MonoDevelop.Projects.Project.NotifyFileAddedToProject (IEnumerable`1 objs) [0x00084] in /private/tmp/source/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs:879 
  at MonoDevelop.Projects.Project.OnItemsAdded (IEnumerable`1 objs) [0x00007] in /private/tmp/source/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs:814 
  at MonoDevelop.Projects.DotNetProject.OnItemsAdded (IEnumerable`1 objs) [0x00000] in /private/tmp/source/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs:1038 
  at MonoDevelop.IPhone.IPhoneProject.OnItemsAdded (IEnumerable`1 objs) [0x00063] in /private/tmp/source/md-addins/MonoDevelop.IPhone/MonoDevelop.IPhone/Project/IPhoneProject.cs:175 
  at MonoDevelop.Projects.ProjectItemCollection`1[MonoDevelop.Projects.ProjectItem].NotifyAdded (IEnumerable`1 items, Boolean comesFromParent) [0x0009a] in /private/tmp/source/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectItemCollection.cs:153 
  at MonoDevelop.Projects.ProjectItemCollection`1[MonoDevelop.Projects.ProjectItem].MonoDevelop.Projects.IItemListHandler.InternalAdd (IEnumerable`1 objs, Boolean comesFromParent) [0x00041] in /private/tmp/source/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectItemCollection.cs:127 
  at MonoDevelop.Projects.ProjectItemCollection`1[MonoDevelop.Projects.ProjectFile].NotifyAdded (IEnumerable`1 items, Boolean comesFromParent) [0x00082] in /private/tmp/source/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectItemCollection.cs:151 
  at MonoDevelop.Projects.ProjectItemCollection`1[MonoDevelop.Projects.ProjectFile].AddRange (IEnumerable`1 items) [0x0003c] in /private/tmp/source/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectItemCollection.cs:71 
  at MonoDevelop.Ide.ProjectOperations.AddFilesToProject (MonoDevelop.Projects.Project project, MonoDevelop.Core.FilePath[] files, MonoDevelop.Core.FilePath[] targetPaths, System.String buildAction) [0x0040d] in /private/tmp/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs:1519 
  at MonoDevelop.Ide.ProjectOperations.AddFilesToProject (MonoDevelop.Projects.Project project, MonoDevelop.Core.FilePath[] files, FilePath targetDirectory, System.String buildAction) [0x00045] in /private/tmp/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs:1368 
  at MonoDevelop.Ide.Gui.Pads.ProjectPad.FolderCommandHandler.AddFilesToProject () [0x000bf] in /private/tmp/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/FolderNodeBuilder.cs:337 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0 
  at MonoDevelop.Components.Commands.DefaultCommandHandler.Run (System.Object target, MonoDevelop.Components.Commands.Command cmd) [0x00018] in /private/tmp/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1542 
  at MonoDevelop.Components.Commands.CustomCommandTargetAttribute.Run (System.Object target, MonoDevelop.Components.Commands.Command cmd) [0x00000] in /private/tmp/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/CustomCommandTargetAttribute.cs:54 
  at MonoDevelop.Ide.Gui.Components.NodeCommandHandler+TransactedNodeHandlerAttribute.Run (System.Object target, MonoDevelop.Components.Commands.Command cmd) [0x00026] in /private/tmp/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/NodeCommandHandler.cs:274 
  at MonoDevelop.Components.Commands.CustomCommandTargetAttribute.MonoDevelop.Components.Commands.ICommandTargetHandler.Run (System.Object target, MonoDevelop.Components.Commands.Command cmd) [0x00000] in /private/tmp/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/CustomCommandTargetAttribute.cs:44 
  at MonoDevelop.Components.Commands.CommandHandlerInfo.Run (System.Object cmdTarget, MonoDevelop.Components.Commands.Command cmd) [0x00017] in /private/tmp/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1430 
  at MonoDevelop.Components.Commands.CommandManager+<DispatchCommand>c__AnonStorey42.<>m__56 () [0x0003d] in /private/tmp/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:644 
  at MonoDevelop.Components.Commands.CommandManager.DispatchCommand (System.Object commandId, System.Object dataItem, System.Object initialTarget, CommandSource source) [0x0029e] in /private/tmp/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:661
Comment 1 Jeffrey Stedfast 2012-01-27 17:14:40 UTC
In 2.8.5 and most of 2.8.6.x's, the code in question is:

268					var running = xcode.CheckRunning ();
269					UpdateXcodeProject (monitor);
270					if (running)
271						xcode.OpenProject (monitor);


Since UpdateXcodeProject() cannot set xcode to null, it *might* be that some other thread went and called DisableSyncing().

I'll let Alan dig into this further and will refrain from ninjaing this bug away from him ;-)

(I'm such a nice guy, aren't I?)
Comment 2 Jeffrey Stedfast 2013-04-02 15:36:29 UTC
this should be fixed. I've added locking to prevent this kind of thing.