I have a web app I am tweaking in VS 2015 but I am receiving a error...see below
Value cannot be null. Parameter name: String
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: Value cannot be null. Parameter name: String
Source Error:
public abstract class MasterPageBase : System.Web.UI.MasterPage
{
private UserPermissions userPermissions = new UserPermissions();
public string SelItem { set; get; }
public RadWindowManager.WindowManager_Notice
...
}
Stack trace:
Stack trace [ArgumentNullException: Value cannot be null.
Parameter name: String]
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +10169561
System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +207
TmsAdministration.SecurityBase..cctor() +43
[TypeInitializationException: The type initializer for 'TmsAdministration.SecurityBase' threw an exception.]
TmsAdministration.UserPermissions.GetUserPermissions(String _sAMAccountName) +339
MasterPageBase..ctor() in c:\inetpub\wwwroot\calrecallnew2\App_Code\MasterPageBase.cs:7
MasterPage..ctor() +41
ASP.masterpage_master..ctor() in c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\calrecallnew2\993de1dc\c159201a\App_Web_qz6jw_eo.2.cs:0
__ASP.FastObjectFactory_app_web_qz6jw_eo.Create_ASP_masterpage_master() in c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\calrecallnew2\993de1dc\c159201a\App_Web_qz6jw_eo.10.cs:0
System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection) +270
System.Web.UI.Page.get_Master() +69
System.Web.UI.Page.ApplyMasterPage() +18
System.Web.UI.Page.PerformPreInit() +58
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1256
this is the line that is causing the error private
---> UserPermissions userPermissions = new UserPermissions();
I am fairly new to c# and was hoping to get some assistance.
UserPermissions code:
public static List<EnumValue> GetUserLocations(TmsAdministration.U serPermissions userPermissions)
{
List<EnumValue> locations = new List<EnumValue>();
foreach (EnumValue value in Values)
{
if (userPermissions.IsInRole(value.Label) == 2 && !locations.Exists(_r => _r.Label == value.Label))
{
locations.Add(value);
}
}
if (locations.Exists(_r => _r.Id == Default.DirectoryId))
{
locations.Remove(locations.Find(_r => _r.Id == Default.DirectoryId));
locations.Insert(0, new EnumValue(Default.DirectoryId, Default.DirectoryName));
}
return locations;
}
}
NameSpace:
namespace TmsAdministration
{
public class UserPermissions
{
public string Email;
public string FirstName;
public bool IgnoreCache;
public string LastName;
public Dictionary<string, int> Roles;
public string sAMAccountName;
public bool UserIsInActiveDirectory;
public UserPermissions();
public UserPermissions(string sAMAccountName);
public UserPermissions(string sAMAccountName, bool ignoreCache);
public string FullName { get; }
public int GetRoleId(string roleName);
public string GetRoleName(int roleId);
public ActiveDirectory.UserInformation GetUserManager();
public List<string> GetUsersDirectReports();
public int IsInRole(int roleId);
public int IsInRole(string roleName);
public virtual void RedirectIfNotInActiveDirectory(Page page, string redirectUrl);
public virtual void RedirectIfNotInRole(Page page, string roleName, int requiredLevel, string redirectUrl);
public virtual void RedirectIfNotInRoles(Page page, List<string> roleNames, List<int> requiredLevels, string redirectUrl);
public void RefreshUser();
}
}