Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gordon Saxby 1444 posts 1855 karma points
    Sep 01, 2009 @ 16:01
    Gordon Saxby
    0

    Object reference not set to an instance of an object

    I have installed uForum, updated the templates to fit into the site design and created a forum. When I tried to add a new topic I got the following error -

     


    Server Error in '/' Application.
    --------------------------------------------------------------------------------

    Object reference not set to an instance of an object.
    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.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:

    The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:

    1. Add a "Debug=true" directive at the top of the file that generated the error. Example:

      <%@ Page Language="C#" Debug="true" %>

    or:

    2) Add the following section to the configuration file of your application:

    <configuration>
       <system.web>
           <compilation debug="true"/>
       </system.web>
    </configuration>

    Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.

    Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.
     

    Stack Trace:

    [NullReferenceException: Object reference not set to an instance of an object.]
       ASP.masterpages_newtopic_master.btCreateTopic_Click(Object sender, EventArgs e) +64
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

     

     

  • Bert 128 posts 251 karma points
    Sep 01, 2009 @ 16:17
    Bert
    0

    Add the following section to the web.config:

    <configuration>
       <system.web>
           <compilation debug="true"/>
       </system.web>
    </configuration>

    And report the exact error you get.

  • Gordon Saxby 1444 posts 1855 karma points
    Sep 01, 2009 @ 16:26
    Gordon Saxby
    0

    Ah ...

     

    Object reference not set to an instance of an object.
    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.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:


    Line 11:                 int forumId = umbraco.presentation.nodeFactory.Node.GetCurrent().Id;
    Line 12:                 umbraco.presentation.nodeFactory.Node n = new umbraco.presentation.nodeFactory.Node(forumId);
    Line 13:                 int _currentMember = umbraco.cms.businesslogic.member.Member.GetCurrentMember().Id;
    Line 14:
    Line 15:                 if (_currentMember > 0 && n != null && umbraco.cms.businesslogic.web.Access.HasAccces(n.Id, _currentMember))
     

    Source File: d:\Intranet\sites\UKPHA2\www\masterpages\NewTopic.master    Line: 13

    Stack Trace:


    [NullReferenceException: Object reference not set to an instance of an object.]
       ASP.masterpages_newtopic_master.btCreateTopic_Click(Object sender, EventArgs e) in d:\Intranet\sites\UKPHA2\www\masterpages\NewTopic.master:13
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
     

    The website uses a "custom" membership provider (i.e. not the standard Umbraco one) ... I assume that's the reason? uForum recognises that I am logged on OK though. Where is the "problem" - uForum or the custom provider?

  • Bert 128 posts 251 karma points
    Sep 01, 2009 @ 17:14
    Bert
    0

    The problem is the compatibility, not one or the other. But i would tinker with the custom membership provider to provide the right methods and results to uForum.

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Sep 01, 2009 @ 21:54
    Morten Bock
    0

    This is the class that is returning null:

            public static Member GetCurrentMember()
    {
    try
    {
    int _currentMemberId = CurrentMemberId();
    if (_currentMemberId != 0)
    {
    // return member from cache
    Member m = GetMemberFromCache(_currentMemberId);
    if (m == null)
    m = new Member(_currentMemberId);

    if (HttpContext.Current.User.Identity.IsAuthenticated || (m.UniqueId == new Guid(getCookieValue("umbracoMemberGuid")) &&
    m.LoginName == getCookieValue("umbracoMemberLogin")))
    return m;

    return null;
    }
    else
    return null;
    }
    catch
    {
    return null;
    }
    }

    This looks for the cookie that Umbraco own membership provider sets. Your provider does not do this, so you need to change the source of uForum to use another way of identifying the current user. Both when posting new topics, but probably also when displaying topics, to display the user name.

  • Gordon Saxby 1444 posts 1855 karma points
    Sep 02, 2009 @ 13:00
    Gordon Saxby
    0

    OK - so I assume that I could update the membership provider to create the same cookie ("umbracoMemberLogin")? I'd rather do as few changes to uForum as possible.

  • Bert 128 posts 251 karma points
    Sep 06, 2009 @ 18:59
    Bert
    0

    yep would be my preferred solution too.

  • davelane 29 posts 73 karma points
    Sep 10, 2009 @ 18:13
    davelane
    0

    Hey guys,

    i'm less of an ASP.NET user than I should be, so can you tell me where I should go to make the edit that Gordon suggests (update the membership providor cookie)

    Thanks very much!!
    Dave

Please Sign in or register to post replies

Write your reply to:

Draft