diff --git a/pkg/CosmosDBStudio.Packaging/Package.appxmanifest b/pkg/CosmosDBStudio.Packaging/Package.appxmanifest
index 68cead2..3388f84 100644
--- a/pkg/CosmosDBStudio.Packaging/Package.appxmanifest
+++ b/pkg/CosmosDBStudio.Packaging/Package.appxmanifest
@@ -9,7 +9,7 @@
+ Version="1.1.1.0" />
Cosmos DB Studio
diff --git a/src/CosmosDBStudio/Services/IQueryPersistenceService.cs b/src/CosmosDBStudio/Services/IQueryPersistenceService.cs
index 1d4f47d..95143bb 100644
--- a/src/CosmosDBStudio/Services/IQueryPersistenceService.cs
+++ b/src/CosmosDBStudio/Services/IQueryPersistenceService.cs
@@ -5,7 +5,7 @@ namespace CosmosDBStudio.Services
{
public interface IQueryPersistenceService
{
- QuerySheet Load(string path);
+ QuerySheet? Load(string path);
void Save(QuerySheet querySheet, string path);
IList LoadMruList();
void SaveMruList(IList mruList);
diff --git a/src/CosmosDBStudio/Services/Implementation/QueryPersistenceService.cs b/src/CosmosDBStudio/Services/Implementation/QueryPersistenceService.cs
index 0281baa..d183ded 100644
--- a/src/CosmosDBStudio/Services/Implementation/QueryPersistenceService.cs
+++ b/src/CosmosDBStudio/Services/Implementation/QueryPersistenceService.cs
@@ -10,10 +10,20 @@ namespace CosmosDBStudio.Services.Implementation
{
public class QueryPersistenceService : IQueryPersistenceService
{
- public QuerySheet Load(string path)
+ public QuerySheet? Load(string path)
{
- string json = File.ReadAllText(path);
- return JsonConvert.DeserializeObject(json);
+ if (File.Exists(path))
+ {
+ try
+ {
+ string json = File.ReadAllText(path);
+ return JsonConvert.DeserializeObject(json);
+ }
+ catch (FileNotFoundException) { }
+ catch (DirectoryNotFoundException) { }
+ }
+
+ return null;
}
public IList LoadMruList()
@@ -85,8 +95,13 @@ public Workspace LoadWorkspace()
var path = Path.Combine(GetWorkspacePath(false), "workspace.json");
if (File.Exists(path))
{
- string json = File.ReadAllText(path);
- return JsonConvert.DeserializeObject(json);
+ try
+ {
+ string json = File.ReadAllText(path);
+ return JsonConvert.DeserializeObject(json);
+ }
+ catch (FileNotFoundException) { }
+ catch (DirectoryNotFoundException) { }
}
return new Workspace();
diff --git a/src/CosmosDBStudio/ViewModel/MainWindowViewModel.cs b/src/CosmosDBStudio/ViewModel/MainWindowViewModel.cs
index cbe642e..0de8735 100644
--- a/src/CosmosDBStudio/ViewModel/MainWindowViewModel.cs
+++ b/src/CosmosDBStudio/ViewModel/MainWindowViewModel.cs
@@ -206,6 +206,9 @@ private void OpenQuerySheet(string path)
}
var querySheet = _queryPersistenceService.Load(path);
+ if (querySheet is null)
+ return;
+
var vm = _viewModelFactory.CreateQuerySheet(
querySheet,
path,
@@ -270,6 +273,8 @@ private void LoadWorkspace()
}
var querySheet = _queryPersistenceService.Load(path);
+ if (querySheet is null)
+ continue;
var vm = _viewModelFactory.CreateQuerySheet(
querySheet,
sheet.SavedPath,