Can't save script in monodevelop

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.IO.IOException: Incorrect function.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.File.InternalMove(String sourceFileName, String destFileName, Boolean checkHost)
at Mono.TextEditor.Utils.TextFileUtility.SystemRename(String sourceFile, String destFile) in c:\buildslave\monodevelop\build\monodevelop\main\src\core\Mono.Texteditor\Mono.TextEditor.Utils\TextFileUtility.cs:line 206
at Mono.TextEditor.Utils.TextFileUtility.WriteText(String fileName, String text, Encoding encoding, Boolean hadBom) in c:\buildslave\monodevelop\build\monodevelop\main\src\core\Mono.Texteditor\Mono.TextEditor.Utils\TextFileUtility.cs:line 193
at MonoDevelop.SourceEditor.SourceEditorView.Save(String fileName, Encoding encoding) in c:\buildslave\monodevelop\build\monodevelop\main\src\addins\MonoDevelop.SourceEditor2\MonoDevelop.SourceEditor\SourceEditorView.cs:line 672
at MonoDevelop.SourceEditor.SourceEditorView.Save(String fileName) in c:\buildslave\monodevelop\build\monodevelop\main\src\addins\MonoDevelop.SourceEditor2\MonoDevelop.SourceEditor\SourceEditorView.cs:line 588
at MonoDevelop.Ide.Gui.Document.Save() in c:\buildslave\monodevelop\build\monodevelop\main\src\core\MonoDevelop.Ide\MonoDevelop.Ide.Gui\Document.cs:line 355
at MonoDevelop.Ide.Gui.ViewCommandHandlers.OnSaveFile() in c:\buildslave\monodevelop\build\monodevelop\main\src\core\MonoDevelop.Ide\MonoDevelop.Ide.Gui\ViewCommandHandlers.cs:line 65
— End of inner exception stack trace —
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object parameters, Object arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object parameters)
at MonoDevelop.Components.Commands.CommandHandlerInfo.Run(Object cmdTarget, Command cmd) in c:\buildslave\monodevelop\build\monodevelop\main\src\core\MonoDevelop.Ide\MonoDevelop.Components.Commands\CommandManager.cs:line 1922
at MonoDevelop.Components.Commands.CommandManager.<>c__DisplayClassb.b__2() in c:\buildslave\monodevelop\build\monodevelop\main\src\core\MonoDevelop.Ide\MonoDevelop.Components.Commands\CommandManager.cs:line 1045
at MonoDevelop.Components.Commands.CommandManager.DispatchCommand(Object commandId, Object dataItem, Object initialTarget, CommandSource source) in c:\buildslave\monodevelop\build\monodevelop\main\src\core\MonoDevelop.Ide\MonoDevelop.Components.Commands\CommandManager.cs:line 1062

It looks like MonoDevelop is trying to save your script file, but there is some kind of exception preventing it. This could be that the file is currently in use by another application or somehow the writing permissions have changed, among some other reasons.

Does this happen repeatedly or just this once? It’s very hard to tell what caused it, but if it’s only a one time issue, you shouldn’t bother much. Just copy your script as text and paste it somewhere else. Abort saving, close all apps, maybe restart your computer and then recreate the script file.

If it happens more than once, you will need to find the exact case in which it is reproducible. With that information, maybe someone can help.