Bug 12399 - Error while executing command: Save
Summary: Error while executing command: Save
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: C# Binding ()
Version: 4.0.6
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: 4.0.9 (from master)
Assignee: Mike Krüger
URL:
Depends on:
Blocks:
 
Reported: 2013-05-27 03:50 UTC by Dylan
Modified: 2013-09-12 06:00 UTC (History)
1 user (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 Dylan 2013-05-27 03:50:00 UTC
With format on save enabled, as soon as I add the following code into a .cs file I get an "Error while executing command: Save". When the code is commented out I can save.

        private void btnAction_Clicked(object sender, EventArgs e)
        {
            var actionSheet = new UIActionSheet("Select an action") {"Map", "Directions", "Call", "Cancel"};
            actionSheet.Style = UIActionSheetStyle.Automatic;
            actionSheet.ShowFromTabBar(TabBarController.TabBar);
            actionSheet.Clicked += (s, ev) => {

            };
        } 


Error details:

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 ICSharpCode.NRefactory.CSharp.FormattingVisitor.VisitArrayInitializerExpression (ICSharpCode.NRefactory.CSharp.ArrayInitializerExpression arrayInitializerExpression) [0x00264] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor_Expressions.cs:515 
  at ICSharpCode.NRefactory.CSharp.ArrayInitializerExpression.AcceptVisitor (IAstVisitor visitor) [0x00000] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ArrayInitializerExpression.cs:108 
  at ICSharpCode.NRefactory.CSharp.FormattingVisitor.VisitArrayInitializerExpression (ICSharpCode.NRefactory.CSharp.ArrayInitializerExpression arrayInitializerExpression) [0x0006e] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor_Expressions.cs:478 
  at ICSharpCode.NRefactory.CSharp.ArrayInitializerExpression.AcceptVisitor (IAstVisitor visitor) [0x00000] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ArrayInitializerExpression.cs:108 
  at ICSharpCode.NRefactory.CSharp.FormattingVisitor.VisitObjectCreateExpression (ICSharpCode.NRefactory.CSharp.ObjectCreateExpression objectCreateExpression) [0x00097] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor_Expressions.cs:460 
  at ICSharpCode.NRefactory.CSharp.ObjectCreateExpression.AcceptVisitor (IAstVisitor visitor) [0x00000] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ObjectCreateExpression.cs:85 
  at ICSharpCode.NRefactory.CSharp.FormattingVisitor.VisitVariableInitializer (ICSharpCode.NRefactory.CSharp.VariableInitializer variableInitializer) [0x00037] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor_Statements.cs:469 
  at ICSharpCode.NRefactory.CSharp.VariableInitializer.AcceptVisitor (IAstVisitor visitor) [0x00000] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/VariableInitializer.cs:154 
  at ICSharpCode.NRefactory.CSharp.FormattingVisitor.VisitVariableDeclarationStatement (ICSharpCode.NRefactory.CSharp.VariableDeclarationStatement variableDeclarationStatement) [0x00086] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor_Statements.cs:429 
  at ICSharpCode.NRefactory.CSharp.VariableDeclarationStatement.AcceptVisitor (IAstVisitor visitor) [0x00000] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Ast/Statements/VariableDeclarationStatement.cs:71 
  at ICSharpCode.NRefactory.CSharp.FormattingVisitor.<VisitBlockWithoutFixingBraces>m__31B (ICSharpCode.NRefactory.CSharp.AstNode child) [0x00038] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor_Statements.cs:53 
  at ICSharpCode.NRefactory.CSharp.FormattingVisitor.VisitChildrenToFormat (ICSharpCode.NRefactory.CSharp.AstNode parent, System.Action`1 callback) [0x00074] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor.cs:99 
  at ICSharpCode.NRefactory.CSharp.FormattingVisitor.VisitBlockWithoutFixingBraces (ICSharpCode.NRefactory.CSharp.BlockStatement blockStatement, Boolean indent) [0x00012] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor_Statements.cs:46 
  at ICSharpCode.NRefactory.CSharp.FormattingVisitor.VisitMethodDeclaration (ICSharpCode.NRefactory.CSharp.MethodDeclaration methodDeclaration) [0x000ad] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor_TypeMembers.cs:338 
  at ICSharpCode.NRefactory.CSharp.MethodDeclaration.AcceptVisitor (IAstVisitor visitor) [0x00000] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/MethodDeclaration.cs:80 
  at ICSharpCode.NRefactory.CSharp.FormattingVisitor.<VisitTypeDeclaration>m__31A (ICSharpCode.NRefactory.CSharp.AstNode child) [0x00023] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor_Global.cs:162 
  at ICSharpCode.NRefactory.CSharp.FormattingVisitor.VisitChildrenToFormat (ICSharpCode.NRefactory.CSharp.AstNode parent, System.Action`1 callback) [0x00074] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor.cs:99 
  at ICSharpCode.NRefactory.CSharp.FormattingVisitor.VisitTypeDeclaration (ICSharpCode.NRefactory.CSharp.TypeDeclaration typeDeclaration) [0x000d9] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor_Global.cs:157 
  at ICSharpCode.NRefactory.CSharp.TypeDeclaration.AcceptVisitor (IAstVisitor visitor) [0x00000] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/TypeDeclaration.cs:107 
  at ICSharpCode.NRefactory.CSharp.FormattingVisitor+<VisitNamespaceDeclaration>c__AnonStorey145.<>m__319 (ICSharpCode.NRefactory.CSharp.AstNode child) [0x000c4] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor_Global.cs:102 
  at ICSharpCode.NRefactory.CSharp.FormattingVisitor.VisitChildrenToFormat (ICSharpCode.NRefactory.CSharp.AstNode parent, System.Action`1 callback) [0x00074] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor.cs:99 
  at ICSharpCode.NRefactory.CSharp.FormattingVisitor.VisitNamespaceDeclaration (ICSharpCode.NRefactory.CSharp.NamespaceDeclaration namespaceDeclaration) [0x00047] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor_Global.cs:82 
  at ICSharpCode.NRefactory.CSharp.NamespaceDeclaration.AcceptVisitor (IAstVisitor visitor) [0x00000] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/NamespaceDeclaration.cs:118 
  at ICSharpCode.NRefactory.CSharp.FormattingVisitor+<VisitSyntaxTree>c__AnonStorey144.<>m__318 (ICSharpCode.NRefactory.CSharp.AstNode child) [0x0005b] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor_Global.cs:57 
  at ICSharpCode.NRefactory.CSharp.FormattingVisitor.VisitChildrenToFormat (ICSharpCode.NRefactory.CSharp.AstNode parent, System.Action`1 callback) [0x00074] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor.cs:99 
  at ICSharpCode.NRefactory.CSharp.FormattingVisitor.VisitSyntaxTree (ICSharpCode.NRefactory.CSharp.SyntaxTree unit) [0x00014] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor_Global.cs:50 
  at ICSharpCode.NRefactory.CSharp.SyntaxTree.AcceptVisitor (IAstVisitor visitor) [0x00000] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Ast/SyntaxTree.cs:140 
  at ICSharpCode.NRefactory.CSharp.CSharpFormatter.AnalyzeFormatting (IDocument document, ICSharpCode.NRefactory.CSharp.SyntaxTree syntaxTree, CancellationToken token) [0x00033] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Formatter/CSharpFormatter.cs:141 
  at MonoDevelop.CSharp.Formatting.OnTheFlyFormatter.GetFormattingChanges (MonoDevelop.Projects.Policies.PolicyContainer policyParent, IEnumerable`1 mimeTypeChain, MonoDevelop.Ide.Gui.Document document, System.String input, DomRegion formattingRegion, System.Int32& formatStartOffset, System.Int32& formatLength, Boolean formatLastStatementOnly) [0x000d1] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/OnTheFlyFormatter.cs:174 
  at MonoDevelop.CSharp.Formatting.OnTheFlyFormatter.Format (MonoDevelop.Projects.Policies.PolicyContainer policyParent, IEnumerable`1 mimeTypeChain, MonoDevelop.Ide.Gui.Document data, Int32 startOffset, Int32 endOffset, Boolean exact, Boolean formatLastStatementOnly) [0x00206] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/OnTheFlyFormatter.cs:245 
  at MonoDevelop.CSharp.Formatting.OnTheFlyFormatter.Format (MonoDevelop.Ide.Gui.Document data, Int32 startOffset, Int32 endOffset, Boolean exact) [0x0002c] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/OnTheFlyFormatter.cs:65 
  at MonoDevelop.CSharp.Formatting.CSharpFormatter.OnTheFlyFormat (MonoDevelop.Ide.Gui.Document doc, Int32 startOffset, Int32 endOffset) [0x00000] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpFormatter.cs:79 
  at MonoDevelop.Ide.CodeFormatting.CodeFormatter.OnTheFlyFormat (MonoDevelop.Ide.Gui.Document doc, Int32 startOffset, Int32 endOffset) [0x00028] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeFormatting/CodeFormatter.cs:102 
  at MonoDevelop.SourceEditor.SourceEditorView.Save (System.String fileName, System.Text.Encoding encoding) [0x00119] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs:624 
  at MonoDevelop.SourceEditor.SourceEditorView.Save (System.String fileName) [0x00000] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs:586 
  at MonoDevelop.Ide.Gui.Document.Save () [0x00136] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs:355 
  at MonoDevelop.Ide.Gui.ViewCommandHandlers.OnSaveFile () [0x00000] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs:65 
  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) [0x000d5] in /private/tmp/source/bockbuild/profiles/mono-2-10/build-root/mono-2.10.12/_build/mono-2.10.12.git/mcs/class/corlib/System.Reflection/MonoMethod.cs:226 
  --- 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) [0x000eb] in /private/tmp/source/bockbuild/profiles/mono-2-10/build-root/mono-2.10.12/_build/mono-2.10.12.git/mcs/class/corlib/System.Reflection/MonoMethod.cs:234 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /private/tmp/source/bockbuild/profiles/mono-2-10/build-root/mono-2.10.12/_build/mono-2.10.12.git/mcs/class/corlib/System.Reflection/MethodBase.cs:96 
  at MonoDevelop.Components.Commands.CommandHandlerInfo.Run (System.Object cmdTarget, MonoDevelop.Components.Commands.Command cmd) [0x00029] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1965 
  at MonoDevelop.Components.Commands.CommandManager+<DispatchCommand>c__AnonStorey75.<>m__C8 () [0x0003d] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1053 
  at MonoDevelop.Components.Commands.CommandManager.DispatchCommand (System.Object commandId, System.Object dataItem, System.Object initialTarget, CommandSource source) [0x002ab] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.8-branch/0a09117d/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1070
Comment 1 Mike Krüger 2013-05-31 03:08:00 UTC
should be fixed in newer versions.
Comment 2 PJ 2013-06-24 16:18:55 UTC
This bug was marked as fixed for Xamarin Studio 4.0.9, which is currently in the beta channel. Try it out!
Comment 3 Dylan 2013-07-08 09:34:33 UTC
I am using 4.0.9 and this is still an issue...

var actionSheet = new UIActionSheet("Select an action") {"Map", "Directions", "Call", "Cancel"};

The above line causes an Error while executing command: Save. 

This resolves the problem:

                    var actionSheet = new UIActionSheet("Select an action");// {"Map", "Directions", "Call", "Cancel"};
                    actionSheet.AddButton("Map");
                    actionSheet.AddButton("Directions");
                    actionSheet.AddButton("Call");
                    actionSheet.AddButton("Cancel");
Comment 4 Mike Krüger 2013-09-12 06:00:05 UTC
it takes a while until my patches land in releases due to Q&A etc.

I verified that's fixed.