During the construction of my Window LoginSystem, a NullReferenceException is being thrown only when running the application through the .exe.
While debugging, everything works perfectly fine however.
Code which calls the LoginSystem window:
LoginSystem ls = new LoginSystem();
ls.Show();
Where I've found the problem to be in my LoginSystem class:
private void Window_Loaded(object sender, RoutedEventArgs e)
{
Login.con = new SqlConnection(ConfigurationManager.ConnectionStrings["thuisDB"].ConnectionString);
...
}
Just in case you're wondering:
public class Login
{
public static SqlConnection con = null;
...
}
Link to stack trace: HERE
PS: This line (Login.con = new SqlConnection(....)
is the first time Login.con
gets called, as the only code using that static var are in a class which LoginSystem is supposed to make.
EDIT: This question is NOT about me asking what a NullRef is or how to fix it, it was merely a single event where I didn't know why it was being thrown & didn't know how to debug it.