I'm having trouble calling a static method from another method.
My static method is in a separate project, but I checked the links and usage statements, and everything seems to be correct. The following is a simplified version.
Static method
namespace Backend
{
static public class StartUpChecks
{
public static void RunAtStart()
{
}
}
}
Windows form
using Backend;
namespace UI
{
public partial class mainForm:Form
{
public mainForm()
{
InitializeComponent();
}
private void mainForm_Load(object sender, EventArgs e)
{
StartUpChecks.RunAtStart();
}
}
}
When I run the program, it just stops. I set a breakpoint in the OnLoad event handler, but it never hits. If I comment on a MessageBox and comment out a method call, the event fires and a message box appears.
VS. Test() StartUpChecks.RunAtStart(). Test() MessageBox. , , Test().
VS , - .
, ?
---
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataSourceManager;
using UserValidator;
namespace Backend
{
static public class StartUpChecks
{
public static void RunAtStart()
{
CheckUserAuthorised();
CheckUserAdmin();
SetConnection("myApplication");
}
private static void SetConnection(string appName)
{
AppControl.Connection = ConnectionSetter.SetConnectionString(appName);
}
private static void CheckUserAuthorised()
{
UserValidation checkMe = new UserValidation(AppControl.Connection);
AppControl.UserIsAuthorised = checkMe.UserIsAuthorised();
}
private static void CheckUserAdmin()
{
UserValidation checkMe = new UserValidation(AppControl.Connection);
AppControl.UserIsAdmin = checkMe.UserIsAdmin();
}
}
}