C# MonoDevelop: Invalid -langversion CS1617

本文关键字:-langversion CS1617 Invalid MonoDevelop | 更新日期: 2023-09-27 18:08:59

我刚刚在Ubuntu 12.04中安装了MonoDevelop 5.0.1,并试图编译一个简单的Hello World。这会导致以下构建错误:

Error CS1617: Invalid -langversion option `Version5'. It must be `ISO-1', `ISO-2', `3', `4', `5', `Default' or `Future' (CS1617)

我查看了所有选项,我发现的所有选项似乎都设置正确。编辑>首选项>>项目。. NET运行时包含Mono 3.2.1 .

我唯一不能访问的部分是Project>Project Options>Build>General,这会导致抛出异常:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Exception: Unknown LangVersion string ''
  at MonoDevelop.CSharp.Project.CSharpCompilerParameters.get_LangVersion () [0x00000] in <filename unknown>:0 
  at MonoDevelop.CSharp.Project.CompilerOptionsPanelWidget..ctor (MonoDevelop.Projects.DotNetProject project) [0x00000] in <filename unknown>:0 
  at MonoDevelop.CSharp.Project.CompilerOptionsPanel.CreatePanelWidget () [0x00000] in <filename unknown>:0 
  at MonoDevelop.Ide.Gui.Dialogs.OptionsDialog.CreatePageWidget (MonoDevelop.Ide.Gui.Dialogs.SectionPage page) [0x00000] in <filename unknown>:0 
  at MonoDevelop.Ide.Gui.Dialogs.OptionsDialog.ShowPage (MonoDevelop.Ide.Extensions.OptionsDialogSection section) [0x00000] in <filename unknown>:0 
  at MonoDevelop.Ide.Gui.Dialogs.OptionsDialog.OnSelectionChanged (System.Object s, System.EventArgs a) [0x00000] in <filename unknown>:0 
  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 System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in <filename unknown>:0 
  at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in <filename unknown>:0 
  at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in <filename unknown>:0 
  at GLib.Signal.ClosureInvokedCB (System.Object o, GLib.ClosureInvokedArgs args) [0x00000] in <filename unknown>:0 
  at GLib.SignalClosure.Invoke (GLib.ClosureInvokedArgs args) [0x00000] in <filename unknown>:0 
  at GLib.SignalClosure.MarshalCallback (IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data) [0x00000] in <filename unknown>:0 

同样的错误已经发生在MonoDevelop 2中。

C# MonoDevelop: Invalid -langversion CS1617

我可能无法为您提供解决方案,但我可以告诉您为什么会发生这种情况-

请访问此链接-

  1. 原因http://msdn.microsoft.com/en-us/library/ydy7a2we(v=vs.90).aspx

  2. Mono Develop System Requirements.

http://monodevelop.com/developers/building_monodevelop

确保MonoDeveloper支持你正在使用的Mono版本

我(认为我)发现了这个问题,现在它似乎工作正常。显然,其中一个项目文件由于某种原因损坏了。删除旧项目并创建新项目有帮助。