#16
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Apr 2007
    Posts
    17
    Rep Power
    0
    hi sir. I've tried looking at this but I don't seem to see any of this as the reason why I got this message. I am using dotnetnuke, a good cms. I created a custom module from the super simple DAL+ tutorial (you can check it out) it works smoothly. I had placed a script block in the .aspx code of my module that works. I THEN COMMENTED OUT ALL OTHER CODE IN THE .ASPX and .ASPX.VB codes except imports, header and end of class declaration, and the control directive.

    e.g.

    in .aspx.vb code:

    imports ...
    imports...
    imports...
    imports...

    Partial Class Something Inherits Something

    End Class

    in .aspx code:

    <@control language="vb" ....................>

    <script>

    this is my working code that automatically logs in a user to dotnetnuke, from clicking a hyperlink from a main website.
    </script>
    ------------------------------------------------------------so that's what's left. THEN, I get the error when I click the Logout button from the dotnetnuke website....

    so sir, do you have any ideas? thanks for imparting your knowledge to a newbie. regards.
  2. #17
  3. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2925
    hello and welcome to aspfree.

    if you want help, you'll have to post full error message
    and the relevant code.

    we don't have telepathic tiaras over here.
  4. #18
  5. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Apr 2007
    Posts
    17
    Rep Power
    0
    Originally Posted by Shadow Wizard
    hello and welcome to aspfree.

    if you want help, you'll have to post full error message
    and the relevant code.

    we don't have telepathic tiaras over here.
    good day sir, thanks for the prompt response! the error is the same name as the thread sir.

    "Object reference not set to an instance of an object error"

    the code I have posted the skeleton of it previously. the .aspx.vb code and the .aspx code.

    do you need the code itself? the explanation as well is in the previous post sir.
  6. #19
  7. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Apr 2007
    Posts
    17
    Rep Power
    0
    this is the original .aspx code:
    Code:
    <%@ Control Language="VB" 
    AutoEventWireup="false"
    CodeFile="SuperSimple.ascx.vb"
    Inherits="DesktopModules_SuperSimple_SuperSimple" %>
    
    Search:&nbsp;
    <asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>&nbsp;
    <asp:Button ID="btnSearch" runat="server" Text="Button" /><br />
    <br /> 
    <asp:GridView ID="GridView1" runat="server">
    </asp:GridView>
    
    this is the original .aspx.vb code:
    
    Imports DotNetNuke
    Imports System.Web.UI
    Imports System.Collections.Generic
    Imports System.Reflection
    Imports DotNetNuke.Security.PortalSecurity
    
    Partial Class DesktopModules_SuperSimple_SuperSimple
    
    Inherits Entities.Modules.PortalModuleBase
    
    Protected Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
    If Not Page.IsPostBack Then
      ShowData("")
    End If
    
    End Sub
    
    Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
    
    ShowData(txtSearch.Text)
    
    End Sub
    
    Private Sub ShowData(ByVal SearchString As String)
    
    Dim mySqlString As New StringBuilder()
    
    mySqlString.Append("SELECT FriendlyName, Description ")
    mySqlString.Append("FROM {databaseOwner}{objectQualifier}DesktopModules ")
    mySqlString.Append("WHERE Description like '%' + @SearchString + '%' ")
    mySqlString.Append("ORDER BY FriendlyName")
    
    Dim myParam As SqlParameter = New SqlParameter("@SearchString", SqlDbType.VarChar, 150)
    
    myParam.Value = SearchString
    
    Me.GridView1.DataSource = CType(DataProvider.Instance().ExecuteSQL(mySqlString.ToString(), myParam), IDataReader)
    
    Me.GridView1.DataBind()
    
    End Sub
    
    End Class

    THEN THIS IS WHAT'S LEFT:

    in the .aspx code:
    Code:
    <%@ Control Language="VB" 
    AutoEventWireup="false"
    CodeFile="SuperSimple.ascx.vb"
    Inherits="DesktopModules_SuperSimple_SuperSimple" %>
    in the .aspx.vb code: next reply....
    Last edited by nofriends; April 17th, 2007 at 06:04 AM. Reason: added [code][/code] tags
  8. #20
  9. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Apr 2007
    Posts
    17
    Rep Power
    0
    Code:
    Imports DotNetNuke
    Imports System.Web.UI
    Imports System.Collections.Generic
    Imports System.Reflection
    Imports DotNetNuke.Security.PortalSecurity
    
    Partial Class DesktopModules_SuperSimple_SuperSimple
    
    Inherits Entities.Modules.PortalModuleBase
    
    End class

    so you see sir, I took out almost everything. then i entered code in the .aspx page:


    <script>

    code that logs in automatically a user that entered a main portal, and then clicked in my dotnetnuke portal.
    </script>


    It all works well. dotnetnuke recognizes the person. but when I try to logout, the error shows up. here is the generic code given to me. next reply
    Last edited by nofriends; April 17th, 2007 at 06:05 AM. Reason: added [code][/code] tags
  10. #21
  11. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Apr 2007
    Posts
    17
    Rep Power
    0
    Code:
    <script runat="server">
        Protected Sub Page_Load(ByVal O As Object, ByVal E As EventArgs)
            
            If Not (Page.IsPostBack) Then
                Dim UserName As String = Request.QueryString("empno")
                Response.Write("pasok 1")
                Dim intUser As Integer = Me.UserId
                If (intUser > 0) Then
        
                Else
                   
                    Dim objUser As UserInfo = UserController.GetUserByName(Me.PortalId, UserName)
       
                    If Not (objUser Is Nothing) And objUser.Membership.Approved And Not (objUser.Membership.LockedOut = True) Then
    
                        UserAuthorized(objUser)
                    End If
                End If
            End If
        End Sub
        
        Private Sub UserAuthorized(ByVal objectUser As UserInfo)
    
            Dim strMessage As String = String.Empty
            Dim updatePassword As Boolean = False
            Dim updateProfile As Boolean = False
    
            Dim UserId As String = objectUser.UserID
            If Not (objectUser.Profile Is Nothing) And Not (objectUser.Profile.PreferredLocale Is Nothing) Then
    
                Localization.SetLanguage(objectUser.Profile.PreferredLocale)
            
            Else
    
                Localization.SetLanguage(PortalSettings.DefaultLanguage)
            End If
    
            UserController.UserLogin(PortalId, objectUser, PortalSettings.PortalName, <ip address>, False)
           
            Try
    
                Response.Redirect("Default.aspx")
    
            Catch ex As Exception
    
                'AddModuleMessage(ex.ToString(), DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.RedError, True)
                
                Response.Write(ex.StackTrace)
            End Try
        End Sub  
    </script>
    -----> I suspect, I dont have a logout mechanism in this module. can you help me? or could it be a different problem that's why the error shows up? thanks sir for the support.
    Last edited by nofriends; April 17th, 2007 at 06:05 AM. Reason: added [code][/code] tags
  12. #22
  13. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2925
    you do have code in there, so I need full error message that contains
    among the rest line number. that line number tells the programmer
    what code cause problems, then the programmer can fix it.
  14. #23
  15. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Apr 2007
    Posts
    17
    Rep Power
    0
    Originally Posted by Shadow Wizard
    you do have code in there, so I need full error message that contains
    among the rest line number. that line number tells the programmer
    what code cause problems, then the programmer can fix it.
    ok sir. but my visual studio cant build the website with debugging, it causes an error so what I do is just alt+f5 and it runs. so I cant really see the error or the line number where there is an error. only that error I gave you, the one that shows up in the site....
  16. #24
  17. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Apr 2007
    Posts
    17
    Rep Power
    0
    Originally Posted by Shadow Wizard
    you do have code in there, so I need full error message that contains
    among the rest line number. that line number tells the programmer
    what code cause problems, then the programmer can fix it.

    I tried to catch the exception nullreferenceexception:

    System.NullReferenceException: Object reference not set to an instance of an object.

    it is found in my page load, more likely to be in because it always said that I have to catch the exception of the italicized part:

    If Not (objUser Is Nothing) And objUser.Membership.Approved And Not (objUser.Membership.LockedOut = True) Then
    UserAuthorized(objUser)
    End If
  18. #25
  19. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2925
    And is not like the "&&" operator - the phrase objUser.Membership.Approved
    will be parsed even when the first phrase is True.
    that's one of the reasons I prefer C language over Basic.

    the only way that I'm aware of in VB is like this:
    Code:
    If Not (objUser Is Nothing) Then
       If objUser.Membership.Approved  And Not (objUser.Membership.LockedOut = True) Then
          UserAuthorized(objUser)
       End If
    End If
    FYI in C# it can be written in much less lines:
    Code:
    if (objUser != null && objUser.Membership.Approved && !objUser.Membership.LockedOut )
       UserAuthorized(objUser);
    see why many programmers prefer this language?
  20. #26
  21. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Apr 2007
    Posts
    17
    Rep Power
    0
    i don't get error anymore because I just catched the error and It seems that the user logs out just fine =P I will do what you suggested since I'm not doing anything else sir thanks!

    by the way, I have a problem with using sessions since I'm very new in asp.net sir... could you please help me in the thread I created? How to use Sessions in asp.net

    I am targeting to have the website be accessible to all users in the intranet, where in they can all log in at the same time. because, i've seen, that if my previous user is logged and another would log in, that one logs in as the previous user. but when the previous user is logged out, the other can log in perfect.(this is using the automatic log in code above)

    about the C#, they say there are really tradeoffs. like in C#, it is not forgiving. you have to type in the correct variable or method or class with proper capitalization. it also uses braces that are not that friendly and C# is not that readable too. that's what they say. and in vb, you could design the forms and it generates the codes for you. so people here encouraged me to use it. =P though I program in java and before in college I used C. =P
  22. #27
  23. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2925
    that if my previous user is logged and another would log in, that one logs in as the previous user
    sounds like basic logic problem, we need to debug this further in other thread.

    like in C#, it is not forgiving. you have to type in the correct variable or method or class with proper capitalization. it also uses braces that are not that friendly and C# is not that readable too
    that's right, but it's very readable to those familiar with the language. same
    for the need to use proper case - you get used to it in some point.

    and in vb, you could design the forms and it generates the codes for you
    same in C# - the designer does not care what language is being used.

    going to look in your thread later.
  24. #28
  25. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Apr 2007
    Posts
    17
    Rep Power
    0
    thanks shadow wizard! nobody helps me here that's why I keep asking sorry I'm really new in to this.

    they say i should use session so that my users can log in simultaneously but I don't know how. all i know about session is that you can use variables across pages because it saves it in the server. so I dont know what it has to do with me not able to log in uniquely for every person.

    so sir shadow, if it is logic problem, i already posted the code i have. perhaps you can give me pointers. thank you very much!

    dose
  26. #29
  27. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2925
    as I said, we'll discuss this in your thread. we've hijacked this thread enough.
  28. #30
  29. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jan 2008
    Posts
    1
    Rep Power
    0

    System.NullReferenceException - Object reference not set to an instance of an object.


    After research i've found the reason behind this issue.Hope below link will make it clear indeed.

    aspspider.info/magicalspell4u/?Quest=SystemNullReferenceException

    -Thanks
    52

Similar Threads

  1. error: object reference not set to an instance of an object
    By aliaga61 in forum .NET Development
    Replies: 4
    Last Post: January 11th, 2005, 12:25 PM
  2. Replies: 0
    Last Post: August 20th, 2004, 08:18 AM
  3. Error: Object reference not set to an instance of an object.
    By zappa_justin in forum .NET Development
    Replies: 6
    Last Post: July 30th, 2004, 02:39 PM
  4. Error - Object reference not set to an instance of an object
    By ajegopinath in forum .NET Development
    Replies: 0
    Last Post: April 28th, 2004, 12:28 AM
  5. Replies: 8
    Last Post: December 29th, 2003, 12:17 AM

IMN logo majestic logo threadwatch logo seochat tools logo