private void TestConnection() { var savedConnection = (Connection)pgOptions.SelectedObject; if (savedConnection.ConnectionType == ConnectionType.Instance) { var getInstanceState = GethService.GetPortAndInstanceUse(savedConnection.RpcPort); if (getInstanceState == GethInstanceState.InstanceRunning) { MessageBoxEx.Show(this, string.Format("RpcPort {0} currently in use", savedConnection.RpcPort), "Block Studio", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } else { GethService.RunGethInstance(savedConnection, true); } } else { var url = savedConnection.Url; var port = savedConnection.RpcPort; var ethereumService = new EthereumService(url, port); try { var version = ethereumService.GetWeb3ClientVersion(); var result = MessageBoxEx.Show(this, "_connection Successful", "Block Studio", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } catch (Exception) { var result = MessageBoxEx.Show(this, string.Format("Could not connect, is Ethereum running on port {0}?", savedConnection.RpcPort), "Block Studio", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); if (result == DialogResult.Retry) { TestConnection(); } } } }