I have two projects in my solution: HomeworkCalendar (VB.net Windows Forms Application) and HWLib (C# .dll Class Library). In the CurrentUser class in the library I have a variable defines as HWLib.User currentUser
. This comes from the User class in HWLib:
namespace HWLib
{
public class User
{
/// <summary>
/// The Name of the User
/// </summary>
public String name = null;
/// <summary>
/// The Age of the User
/// </summary>
public int age = 0;
/// <summary>
/// The School Type of the User
/// </summary>
public String school = null;
/// <summary>
/// The Amount of Classes the User
/// </summary>
public int classesCount = 0;
/// <summary>
/// The String Array that holds all the classes
/// </summary>
public string[] classes;
}
}
Here is as it is in the CurrentUser class
public class CurrentUser
{
/// <summary>
/// The current User using the program
/// </summary>
public static HWLib.User currentUser;
}
So I attempted to store the user information into this variable, but this is where I get a NullReferenceException
Try
If intClasses <= 11 Then
CurrentUser.currentUser.name = txtName.Text
CurrentUser.currentUser.classesCount = intClasses
CurrentUser.currentUser.school = cboSchool.SelectedItem
CurrentUser.currentUser.age = Convert.ToInt32(cboAge.SelectedItem)
End if
Catch exx As NullReferenceException
'It does catch! This is the issue! Why does it catch here and how do I fix it?
File.Delete(Base.filePath)
MsgBox(exx.ToString())
End Try