Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

MonoDevelop crash on opening one particular class

Discussion in 'Editor & General Support' started by Deeperbeige, May 12, 2013.

  1. Deeperbeige

    Deeperbeige

    Joined:
    May 12, 2013
    Posts:
    14
    MonoDevelop is pretty stable for me, except when I try to open my App.cs class (which is an abstract singleton that manages various startup jobs in my game like loading the player's saves from disk etc). The code appears, then a second or two later I get a lengthy exception (below) and Mono vanishes. The class compiles and works fine in Unity itself.

    Rather than post up the whole 130 line class, I'll just post the bits that look off the beaten track to me:

    It's the only place I use Reflection
    Code (csharp):
    1.  
    2. using System.Reflection;
    3. using Holoville.HOTween;
    4.  
    And I'm using this directive to automatically version my builds with unique IDs (the *.* part gets replaced with a sort of encoded version of the date/time of compilation):
    Code (csharp):
    1.  
    2. [assembly: AssemblyVersion("1.0.*.*")]
    3.  
    It's the only place I use conditional compilation and a vibration plugin from the asset store:
    Code (csharp):
    1.  
    2.         #if UNITY_ANDROID
    3.         vibrator.Vibrate(ms);  
    4.         #endif
    5.        
    6.         #if UNITY_IOS
    7.         Handheld.Vibrate();
    8.         #endif
    9.  
    This is the exception from MonoDevelop:
    Code (csharp):
    1.  
    2. System.InvalidOperationException: Sequence contains no elements
    3.    at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
    4.    at ICSharpCode.NRefactory.CSharp.CSharpParser.ConversionVisitor.ConvertAttributeSection(List`1 optAttributes) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\contrib\ICSharpCode.NRefactory\CSharp\Parser\CSharpParser.cs:line 261
    5.    at ICSharpCode.NRefactory.CSharp.CSharpParser.ConversionVisitor.AddAttributeSection(AstNode parent, Attributes attrs) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\contrib\ICSharpCode.NRefactory\CSharp\Parser\CSharpParser.cs:line 827
    6.    at ICSharpCode.NRefactory.CSharp.CSharpParser.ConversionVisitor.AddAttributeSection(AstNode parent, Attributable a) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\contrib\ICSharpCode.NRefactory\CSharp\Parser\CSharpParser.cs:line 819
    7.    at ICSharpCode.NRefactory.CSharp.CSharpParser.ConversionVisitor.Visit(Class c) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\contrib\ICSharpCode.NRefactory\CSharp\Parser\CSharpParser.cs:line 390
    8.    at Mono.CSharp.Class.Accept(StructuralVisitor visitor) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\contrib\ICSharpCode.NRefactory\CSharp\Parser\mcs\class.cs:line 2516
    9.    at Mono.CSharp.StructuralVisitor.VisitNamespaceBody(Namespace nspace) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\contrib\ICSharpCode.NRefactory\CSharp\Parser\mcs\visit.cs:line 59
    10.    at ICSharpCode.NRefactory.CSharp.CSharpParser.ConversionVisitor.Visit(Namespace nspace) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\contrib\ICSharpCode.NRefactory\CSharp\Parser\CSharpParser.cs:line 297
    11.    at Mono.CSharp.UsingsBag.Namespace.Accept(StructuralVisitor visitor) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\contrib\ICSharpCode.NRefactory\CSharp\Parser\mcs\location.cs:line 782
    12.    at ICSharpCode.NRefactory.CSharp.CSharpParser.Parse(CompilerCompilationUnit top, Int32 line) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\contrib\ICSharpCode.NRefactory\CSharp\Parser\CSharpParser.cs:line 3411
    13.    at MonoDevelop.CSharp.Parser.McsParser.Parse(ProjectDom dom, String fileName, String content) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\src\addins\CSharpBinding\MonoDevelop.CSharp.Parser\McsParser.cs:line 137
    14.    at MonoDevelop.Projects.Dom.Parser.ProjectDomService.DoParseFile(ProjectDom dom, String fileName, String fileContent) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\src\core\MonoDevelop.Core\MonoDevelop.Projects.Dom.Parser\ProjectDomService.cs:line 975
    15.    at MonoDevelop.Projects.Dom.Parser.ProjectDomService.ParseFile(ProjectDom dom, String fileName, Func`1 getContent) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\src\core\MonoDevelop.Core\MonoDevelop.Projects.Dom.Parser\ProjectDomService.cs:line 251
    16.    at MonoDevelop.Projects.Dom.Parser.ProjectDomService.ParseFile(ProjectDom dom, String fileName) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\src\core\MonoDevelop.Core\MonoDevelop.Projects.Dom.Parser\ProjectDomService.cs:line 244
    17.    at MonoDevelop.Projects.Dom.Parser.ProjectDomService.GetParsedDocument(ProjectDom dom, String fileName) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\src\core\MonoDevelop.Core\MonoDevelop.Projects.Dom.Parser\ProjectDomService.cs:line 265
    18.    at MonoDevelop.CSharp.Highlighting.CSharpSyntaxMode.CSharpSpanParser.ConditinalExpressionEvaluator..ctor(Document doc) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\src\addins\CSharpBinding\MonoDevelop.CSharp.Highlighting\CSharpSyntaxMode.cs:line 442
    19.    at MonoDevelop.CSharp.Highlighting.CSharpSyntaxMode.CSharpSpanParser.ScanSpan(Int32 i) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\src\addins\CSharpBinding\MonoDevelop.CSharp.Highlighting\CSharpSyntaxMode.cs:line 540
    20.    at Mono.TextEditor.Highlighting.SyntaxMode.SpanParser.ParseSpans(Int32 offset, Int32 length) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\src\core\Mono.Texteditor\Mono.TextEditor.Highlighting\SyntaxMode.cs:line 453
    21.    at Mono.TextEditor.Highlighting.SyntaxMode.ChunkParser.GetChunks(Int32 offset, Int32 length) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\src\core\Mono.Texteditor\Mono.TextEditor.Highlighting\SyntaxMode.cs:line 657
    22.    at Mono.TextEditor.Highlighting.SyntaxMode.GetChunks(Document doc, ColorSheme style, LineSegment line, Int32 offset, Int32 length) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\src\core\Mono.Texteditor\Mono.TextEditor.Highlighting\SyntaxMode.cs:line 78
    23.    at Mono.TextEditor.TextViewMargin.GetCachedChunks(SyntaxMode mode, Document doc, ColorSheme style, LineSegment line, Int32 offset, Int32 length) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\src\core\Mono.Texteditor\Mono.TextEditor\TextViewMargin.cs:line 859
    24.    at Mono.TextEditor.TextViewMargin.<>c__DisplayClassd.<CreateLinePartLayout>b__a(LayoutWrapper wrapper) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\src\core\Mono.Texteditor\Mono.TextEditor\TextViewMargin.cs:line 1048
    25.    at Mono.TextEditor.TextViewMargin.GetCachedLayout(LineSegment line, Int32 offset, Int32 length, Int32 selectionStart, Int32 selectionEnd, Action`1 createNew) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\src\core\Mono.Texteditor\Mono.TextEditor\TextViewMargin.cs:line 796
    26.    at Mono.TextEditor.TextViewMargin.CreateLinePartLayout(SyntaxMode mode, LineSegment line, Int32 logicalRulerColumn, Int32 offset, Int32 length, Int32 selectionStart, Int32 selectionEnd) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\src\core\Mono.Texteditor\Mono.TextEditor\TextViewMargin.cs:line 1040
    27.    at Mono.TextEditor.TextViewMargin.VisualLocationTranslator.PointToLocation(Double xp, Double yp) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\src\core\Mono.Texteditor\Mono.TextEditor\TextViewMargin.cs:line 2351
    28.    at Mono.TextEditor.TextEditor.ShowTooltip(ModifierType modifierState) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\src\core\Mono.Texteditor\Mono.TextEditor\TextEditor.cs:line 2325
    29.    at Mono.TextEditor.TextEditor.FireMotionEvent(Double x, Double y, ModifierType state) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\src\core\Mono.Texteditor\Mono.TextEditor\TextEditor.cs:line 1152
    30.    at Mono.TextEditor.TextEditor.OnMotionNotifyEvent(EventMotion e) in c:\BuildAgent\work\f07246b5212f7be4\monodevelop\main\src\core\Mono.Texteditor\Mono.TextEditor\TextEditor.cs:line 1110
    31.    at Gtk.Widget.motionnotifyevent_cb(IntPtr widget, IntPtr evnt)
    32.  
     
  2. Deeperbeige

    Deeperbeige

    Joined:
    May 12, 2013
    Posts:
    14
    Figured this out in the end, with a friend of mine who knows C# far better than me. The automatic version attribute is meant to be in an AssemblyInfo.cs file, in a Properties folder. As soon as I did that, MonoDevelop could open all my files again without crashing. Hope this saves someone from the same issue in the future.