Merge pull request #786 from brucetp/MR-421_The_startup_connection_file_could_not_be_loaded

MR-421 The startup connection file could not be loaded
This commit is contained in:
David Sparer
2017-11-11 21:07:46 -06:00
committed by GitHub
6 changed files with 124 additions and 8 deletions

View File

@@ -0,0 +1,21 @@
using mRemoteNG.Config.Connections;
using mRemoteNGTests.TestHelpers;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace mRemoteNGTests.Config.Connections
{
class XmlConnectionsLoaderTests
{
[Test]
public void ThrowsFileNotFound()
{
Assert.Throws<FileNotFoundException>(() => (new XmlConnectionsLoader(FileTestHelpers.NewTempFilePath())).Load());
}
}
}

View File

@@ -138,7 +138,49 @@ namespace mRemoteNG.App
if (ex is FileNotFoundException && !withDialog)
{
MessageCollector.AddExceptionMessage(string.Format(Language.strConnectionsFileCouldNotBeLoadedNew, connectionsLoader.ConnectionFileName), ex, MessageClass.InformationMsg);
ConnectionsService.NewConnections(connectionsLoader.ConnectionFileName);
string[] commandButtons =
{
Language.ConfigurationCreateNew,
Language.ConfigurationCustomPath,
Language.ConfigurationImportFile,
Language.strMenuExit
};
bool answered = false;
while (!answered)
{
try
{
CTaskDialog.ShowTaskDialogBox(GeneralAppInfo.ProductName, Language.ConfigurationFileNotFound, "", "", "", "", "", string.Join(" | ", commandButtons), ETaskDialogButtons.None, ESysIcons.Question, ESysIcons.Question);
switch (CTaskDialog.CommandButtonResult)
{
case 0:
ConnectionsService.NewConnections(connectionsLoader.ConnectionFileName);
answered = true;
break;
case 1:
LoadConnections(true);
answered = true;
break;
case 2:
ConnectionsService.NewConnections(connectionsLoader.ConnectionFileName);
Import.ImportFromFile(ConnectionsService.ConnectionTreeModel.RootNodes[0]);
answered = true;
break;
case 3:
Application.Exit();
answered = true;
break;
}
}
catch (Exception exc)
{
MessageCollector.AddExceptionMessage(string.Format(Language.strConnectionsFileCouldNotBeLoadedNew, connectionsLoader.ConnectionFileName), exc, MessageClass.InformationMsg);
}
}
return;
}

View File

@@ -4,6 +4,7 @@ using mRemoteNG.Config.DataProviders;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Tools;
using mRemoteNG.Tree;
using System.IO;
namespace mRemoteNG.Config.Connections
{
@@ -16,6 +17,9 @@ namespace mRemoteNG.Config.Connections
if (string.IsNullOrEmpty(connectionFilePath))
throw new ArgumentException($"{nameof(connectionFilePath)} cannot be null or empty");
if (!File.Exists(connectionFilePath))
throw new FileNotFoundException($"{connectionFilePath} does not exist");
_connectionFilePath = connectionFilePath;
}

View File

@@ -33,6 +33,7 @@ namespace mRemoteNG.Connection
ConnectionTreeModel = newConnectionsModel,
ConnectionFileName = filename
};
connectionSaver.SaveFilter = new Security.SaveFilter();
connectionSaver.SaveConnections();
// Load config

View File

@@ -1,4 +1,4 @@
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
@@ -60,6 +60,42 @@ namespace mRemoteNG
}
}
/// <summary>
/// Looks up a localized string similar to Create a New Configuration File.
/// </summary>
internal static string ConfigurationCreateNew {
get {
return ResourceManager.GetString("ConfigurationCreateNew", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Use a Custom File Path.
/// </summary>
internal static string ConfigurationCustomPath {
get {
return ResourceManager.GetString("ConfigurationCustomPath", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The Configuration File is Missing..
/// </summary>
internal static string ConfigurationFileNotFound {
get {
return ResourceManager.GetString("ConfigurationFileNotFound", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Import an Existing File.
/// </summary>
internal static string ConfigurationImportFile {
get {
return ResourceManager.GetString("ConfigurationImportFile", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Could not find external tool with name &quot;{0}&quot;.
/// </summary>
@@ -68,8 +104,8 @@ namespace mRemoteNG
return ResourceManager.GetString("CouldNotFindExternalTool", resourceCulture);
}
}
/// <summary>
/// <summary>
/// Looks up a localized string similar to Credentials.
/// </summary>
internal static string Credentials {
@@ -539,7 +575,7 @@ namespace mRemoteNG
/// <summary>
/// Looks up a localized string similar to You cannot import a normal connection file.
///Please use File - Load Connections for normal connection files!.
///Please use File - Open Connection File for normal connection files!.
/// </summary>
internal static string strCannotImportNormalSessionFile {
get {
@@ -677,7 +713,7 @@ namespace mRemoteNG
/// Looks up a localized string similar to The (RDP) Sessions feature requires that you have a copy of eolwtscom.dll registered on your system.
///mRemoteNG ships with this component but it is not registered automatically if you do not use the mRemoteNG Installer.
///To register it manually, run the following command from an elevated command prompt: regsvr32 &quot;C:\Program Files\mRemoteNG\eolwtscom.dll&quot; (where C:\Program Files\mRemoteNG\ is the path to your mRemoteNG installation).
///If this check still fails or you are unable to use the (RDP) Sessions feature [rest of string was truncated]&quot;;.
///If this check still fails or you are unable to use the (RDP) Sessions feat [rest of string was truncated]&quot;;.
/// </summary>
internal static string strCcEOLFailed {
get {
@@ -698,7 +734,7 @@ namespace mRemoteNG
/// Looks up a localized string similar to To use the Gecko Rendering Engine you need to have XULrunner 1.8.1.x and the path to the installation set in your Options.
///You can download XULrunner 1.8.1.3 here: ftp://ftp.mozilla.org/pub/xulrunner/releases/1.8.1.3/contrib/win32/
///When you are finished downloading extract the package to a path of your choice. Then in mRemoteNG go to Tools - Options - Advanced and enter the correct path in the XULrunner path field.
///If you are still not able to pass this check or use the Gecko Engine in mRemoteNG please cons [rest of string was truncated]&quot;;.
///If you are still not able to pass this check or use the Gecko Engine in mRemoteNG please c [rest of string was truncated]&quot;;.
/// </summary>
internal static string strCcGeckoFailed {
get {
@@ -718,7 +754,7 @@ namespace mRemoteNG
/// <summary>
/// Looks up a localized string similar to ICA requires that the XenDesktop Online Plugin is installed and that the wfica.ocx library is registered. You can download the client here: http://www.citrix.com/download/
///If you have the XenDesktop Online Plugin installed and the check still fails, try to register wfica.ocx manually.
///To do this open up the run dialog (Start - Run) and enter the following: regsvr32 &quot;c:\Program Files\Citrix\ICA Client\wfica.ocx&quot; (Where c:\Program Files\Citrix\ICA Client\ is the path to your XenDesktop Online Plugin installat [rest of string was truncated]&quot;;.
///To do this open up the run dialog (Start - Run) and enter the following: regsvr32 &quot;c:\Program Files\Citrix\ICA Client\wfica.ocx&quot; (Where c:\Program Files\Citrix\ICA Client\ is the path to your XenDesktop Online Plugin install [rest of string was truncated]&quot;;.
/// </summary>
internal static string strCcICAFailed {
get {

View File

@@ -2598,4 +2598,16 @@ This page will walk you through the process of upgrading your connections file o
<data name="CouldNotFindExternalTool" xml:space="preserve">
<value>Could not find external tool with name "{0}"</value>
</data>
<data name="ConfigurationCreateNew" xml:space="preserve">
<value>Create a New Configuration File</value>
</data>
<data name="ConfigurationFileNotFound" xml:space="preserve">
<value>The Configuration File is Missing.</value>
</data>
<data name="ConfigurationImportFile" xml:space="preserve">
<value>Import an Existing File</value>
</data>
<data name="ConfigurationCustomPath" xml:space="preserve">
<value>Use a Custom File Path</value>
</data>
</root>