简体   繁体   中英

C# MonoDevelop: Invalid -langversion CS1617

I just installed MonoDevelop 5.0.1 in Ubuntu 12.04 and tried to compile a simple Hello World. This results in the following build error:

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

I looked through the options and everything I found seems to be set up correctly. Edit>Preferences>Projects>.NET Runtimes has Mono 3.2.1 included.

The only section I cannot access is Project>Project Options>Build>General, which causes an Exception to be thrown:

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 

The same error already occurred in MonoDevelop 2.something from the Ubuntu package manager.

I can't help you with the solution may be, but I can give you why this is happening -

Please visit this links -

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

  2. Mono Develop System Requirements.

http://monodevelop.com/developers/building_monodevelop

Make sure that MonoDeveloper supports the Mono version you are using.

I (think I) found the issue and now it appears to be working correctly. Apparently, one of the project files was corrupted for some reason. Deleting the old project and creating a new one helped.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM