Skip to content
This repository was archived by the owner on Oct 4, 2021. It is now read-only.

Commit 7f85dda

Browse files
mrwardmonojenkins
authored andcommitted
[Ide] Handle unauthorized access exception on startup
Handle an UnauthorizedAccessException when trying to determine if the filename passed as a startup argument is a workspace item. The exception is caught and logged and return a non-zero exit code. Previously this would generate a fatal exception. System.IO.FileStream..ctor(String,FileMode,FileAccess,FileShare,Int32,Boolean,FileOptions) System.IO.FileStream..ctor(String,FileMode,FileAccess,FileShare,Int32,FileOptions) System.IO.StreamReader..ctor(String,Encoding,Boolean,Int32) System.IO.StreamReader..ctor(String,Boolean) System.IO.StreamReader..ctor(String) MonoDevelop.Projects.MSBuild.SlnFile.GetFileVersion(String) MonoDevelop.Projects.MSBuild.SlnFileFormat.CanReadFile(String,MSBuildFileFormat) MonoDevelop.Projects.MSBuild.MSBuildFileFormat.CanReadFile(FilePath,Type) MonoDevelop.Projects.MSBuildSerializationExtension.CanRead(FilePath,Type) MonoDevelop.Projects.ProjectService.GetObjectReaderForFile(FilePath,Type) MonoDevelop.Projects.ProjectService.FileIsObjectOfType(FilePath,Type) MonoDevelop.Projects.ProjectService.IsWorkspaceItemFile(FilePath) MonoDevelop.Ide.IdeStartup.Run(MonoDevelopOptions) MonoDevelop.Ide.IdeStartup.Main(String[],IdeCustomizer) Fixes VSTS #1005197 - [FATAL] System.UnauthorizedAccessException exception in System.IO.FileStream..ctor()
1 parent 7965de4 commit 7f85dda

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,14 @@ int Run (MonoDevelopOptions options)
187187

188188
if (!options.NewWindow && startupInfo.HasFiles) {
189189
foreach (var file in startupInfo.RequestedFileList) {
190-
if (MonoDevelop.Projects.Services.ProjectService.IsWorkspaceItemFile (file.FileName)) {
191-
options.NewWindow = true;
192-
break;
190+
try {
191+
if (MonoDevelop.Projects.Services.ProjectService.IsWorkspaceItemFile (file.FileName)) {
192+
options.NewWindow = true;
193+
break;
194+
}
195+
} catch (UnauthorizedAccessException ex) {
196+
LoggingService.LogError (string.Format ("Unable to check startup file is a workspace item '{0}'", file.FileName), ex);
197+
return 1;
193198
}
194199
}
195200
}

0 commit comments

Comments
 (0)