When the AlertsSettings.xml is not present the Appsettings is assigned to nothing. The variables that follow that definition rely on the existance of that information which will normally be set by the load method. But when there is a problem and either of the variables do not get a value how do I handle that in the code that relies on those values. The Settings class deserializes an xml document and assigned values to properties. Thanks.
Sub Main()
Dim Appsettings As Settings = Settings.Load("AlertsSettings.xml")
Dim AlertsServer As String
Dim AlertsDB As String
Dim AlertsUser As String
Dim AlertsPW As String
Dim AlertsConString As String
AlertsServer = Appsettings.ALERTSServer
AlertsDB = Appsettings.ALERTSDatabase
AlertsUser = Appsettings.ALERTSUser
AlertsPW = Appsettings.ALERTSPassword
AlertsConString = "Data Source=" + AlertsServer + _
";Initial Catalog=" + AlertsDB + _
";User ID=" + AlertsUser + _
";Password=" + AlertsPW
Console.WriteLine(AlertsConString)
Console.WriteLine("ok")
End Sub
Sub Main()
Dim Appsettings As Settings = Settings.Load("AlertsSettings.xml")
Dim AlertsServer As String
Dim AlertsDB As String
Dim AlertsUser As String
Dim AlertsPW As String
Dim AlertsConString As String
AlertsServer = Appsettings.ALERTSServer
AlertsDB = Appsettings.ALERTSDatabase
AlertsUser = Appsettings.ALERTSUser
AlertsPW = Appsettings.ALERTSPassword
AlertsConString = "Data Source=" + AlertsServer + _
";Initial Catalog=" + AlertsDB + _
";User ID=" + AlertsUser + _
";Password=" + AlertsPW
Console.WriteLine(AlertsConString)
Console.WriteLine("ok")
End Sub