diff --git a/src/ServiceBusExplorer/App.config b/src/ServiceBusExplorer/App.config
index b957634f..19c74d8b 100644
--- a/src/ServiceBusExplorer/App.config
+++ b/src/ServiceBusExplorer/App.config
@@ -55,7 +55,7 @@
-
+
diff --git a/src/ServiceBusExplorer/Forms/ConnectForm.cs b/src/ServiceBusExplorer/Forms/ConnectForm.cs
index d239867b..6d141e37 100644
--- a/src/ServiceBusExplorer/Forms/ConnectForm.cs
+++ b/src/ServiceBusExplorer/Forms/ConnectForm.cs
@@ -593,15 +593,19 @@ private void btnSave_Click(object sender, EventArgs e)
{
var key = cboServiceBusNamespace.Text;
var isNewServiceBusNamespace = (key == EnterConnectionString);
+
ServiceBusConnectionStringBuilder serviceBusConnectionStringBuilder;
+
try
{
BuildCurrentConnectionString();
+
if (string.IsNullOrWhiteSpace(ConnectionString))
{
MainForm.StaticWriteToLog(ConnectionStringCannotBeNull);
return;
}
+
serviceBusConnectionStringBuilder = new ServiceBusConnectionStringBuilder(ConnectionString);
}
catch (Exception)
@@ -621,10 +625,10 @@ private void btnSave_Click(object sender, EventArgs e)
var index = host.IndexOf(".", StringComparison.Ordinal);
-
if (isNewServiceBusNamespace)
{
key = index > 0 ? CultureInfo.CurrentCulture.TextInfo.ToTitleCase(host.Substring(0, index)) : "MyNamespace";
+
using (var parameterForm = new ParameterForm("Enter the key for the Service Bus namespace",
new List { "Key" },
new List { key },
@@ -644,6 +648,7 @@ private void btnSave_Click(object sender, EventArgs e)
MainForm.StaticWriteToLog("The key of the Service Bus namespace cannot be null.");
return;
}
+
var value = ConnectionString;
try
@@ -663,6 +668,7 @@ private void btnSave_Click(object sender, EventArgs e)
}
serviceBusHelper.ServiceBusNamespaces[key] = ServiceBusNamespace.GetServiceBusNamespace(key, value, MainForm.StaticWriteToLog);
+
cboServiceBusNamespace.Items.Clear();
cboServiceBusNamespace.Items.Add(SelectServiceBusNamespace);
cboServiceBusNamespace.Items.Add(EnterConnectionString);
diff --git a/src/ServiceBusExplorer/Forms/MainForm.cs b/src/ServiceBusExplorer/Forms/MainForm.cs
index 2c2d3e83..6c4d0563 100644
--- a/src/ServiceBusExplorer/Forms/MainForm.cs
+++ b/src/ServiceBusExplorer/Forms/MainForm.cs
@@ -4041,7 +4041,14 @@ private void SetTitle(string prefix)
#region Public Static Methods
public static void StaticWriteToLog(string message, bool async = true)
{
- mainSingletonMainForm.WriteToLog(message);
+ if(mainSingletonMainForm != null)
+ {
+ mainSingletonMainForm.WriteToLog(message);
+ }
+ else
+ {
+ MessageBox.Show(message);
+ }
}
#endregion
diff --git a/src/ServiceBusExplorer/Program.cs b/src/ServiceBusExplorer/Program.cs
index 9d4caf03..045a3311 100644
--- a/src/ServiceBusExplorer/Program.cs
+++ b/src/ServiceBusExplorer/Program.cs
@@ -97,7 +97,16 @@ static void HandleException(Exception ex)
{
if (ex != null && !string.IsNullOrWhiteSpace(ex.Message))
{
- MainForm.StaticWriteToLog(string.Format(CultureInfo.CurrentCulture, ExceptionFormat, ex.Message));
+ var message = ex.Message;
+
+ if (ex.GetType() == typeof(TypeInitializationException))
+ {
+ message += Environment.NewLine + Environment.NewLine +
+ "This may be due to an invalid configuration file.";
+ }
+
+ MainForm.StaticWriteToLog(string.Format(CultureInfo.CurrentCulture, ExceptionFormat, message));
+
if (ex.InnerException != null && !string.IsNullOrWhiteSpace(ex.InnerException.Message))
{
MainForm.StaticWriteToLog(string.Format(CultureInfo.CurrentCulture, InnerExceptionFormat, ex.InnerException.Message));