-4

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();

}

}

  • 4
    You need to show the source code of `GetUserPermissions` that is more likely where the error is. – dmeglio Sep 14 '15 at 13:04
  • 9
    Didn't you ask the same question 2 days ago as an another user? http://stackoverflow.com/questions/32526059/c-sharp-value-cannot-be-null – David Ferenczy Rogožan Sep 14 '15 at 13:06
  • Welcome to StackOverflow. So far this question is not answerable as it doesn't contain releant information. Please refer to the [FAQ](http://stackoverflow.com/help/how-to-ask) for hints on how to improve it so someone could actually answer it. Particularly, you'd absolutely need to show `UserPermissions` code, and please fix the formatting. Also, just showing the traceback and code is often not sufficient. We're glad to help, if you're showing some effort to fix your problem on your side. So far the effort is not shown, unfortunately. – J0HN Sep 14 '15 at 13:07
  • @J0HN What's worse, he's posting the same question as a different user again, see http://stackoverflow.com/questions/32526059/c-sharp-value-cannot-be-null (it had completely the same "formatting" originally). This shouldn't be tolerated. – David Ferenczy Rogožan Sep 14 '15 at 13:10
  • possible duplicate of [What is a NullReferenceException and how do I fix it?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Rowland Shaw Sep 14 '15 at 13:10
  • The previous account was made by a Co worker I didn't authorize to be made and connected to my Facebook account which is why I created another account. I have tried a few different options and still getting the same error. I will post the user permissions code. – user5333955 Sep 14 '15 at 13:11
  • @DawidFerenczy yeah, I saw your comment after psoting mine. Already voted to close. – J0HN Sep 14 '15 at 13:12
  • What did you choose as a reason? – David Ferenczy Rogožan Sep 14 '15 at 13:13
  • @DawidFerenczy I'm sorry but please you have no idea as to what happened. I am not trying to get one over I ask a coworker to post a question and they signed up via the wrong account which is why I started my own account. – user5333955 Sep 14 '15 at 13:13
  • @user5333955 Try to improve your question so it's answerable before it's closed. But I guess you have to be fast. – David Ferenczy Rogožan Sep 14 '15 at 13:15
  • Where is the source code for userPermissions found...this was built by someone else – user5333955 Sep 14 '15 at 13:16
  • What happened is irrelevant, What's relevant is that the question is not answerable, has formatting issues (read: shows disrespect, since you haven't spent 10-15 minute to learn the formatting applied) and so on. @DawidFerenczy if you're interested (not sure why) - not answerable. – J0HN Sep 14 '15 at 13:16
  • @J0HN Thanks. Just curious what would be the proper reason in this case. It' s not possible to flag it as a duplicate of previous, since previous is not answered. – David Ferenczy Rogožan Sep 14 '15 at 13:18
  • Per my reading it states indent code by four space which I did. I didn't add the user permissions source code which I am trying to get now. I'm asking for help not to be scrutinized for things I am unaware of. – user5333955 Sep 14 '15 at 13:19
  • Added get permissions source code I believe. Sorry I am a super noob when it comes to asp.net and c# – user5333955 Sep 14 '15 at 13:35
  • @DawidFerenczy I've added more to the question. I've slso tried including the namespace. Etc...still no luck...how can I get my question reviewed again? – user5333955 Sep 14 '15 at 17:38
  • Can someone provide direction as to what I should do to have my question viewed? – user5333955 Sep 15 '15 at 13:27

1 Answers1

0

I suspect something inside the constructor for UserPermissions is failing.

Probably, you're missing the username of the account you want to obtain the permissions for.

Russ Clarke
  • 17,511
  • 4
  • 41
  • 45
  • Thanks for your input. I have added another code snippet hopefully it is what we are looking for. Can you provide any further insight. Coding examples would be most welcome. Thanks – user5333955 Sep 14 '15 at 14:53