Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsRepositoryRepositoryDashboard - Object reference not set to an instance of an object.Dashboard - Object reference not set to an instance of an object.
Previous
 
Next
New Post
9/12/2007 5:23 PM
 

OK... after a few hours work I've gotten half a development environment up and running....

Using the debug code shown below.(the it String) I think I've discovered that there's a repository left around in our database which isn't on a tab...

 

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load' Obtain PortalSettings from Current Context

 

 

Dim _portalSettings As PortalSettings = CType(HttpContext.Current.Items("PortalSettings"), PortalSettings)Dim it As String

it =

"Test... "

 

Try

 

' Get settings from the database

 

it +=

Dim settings As Hashtable = PortalSettings.GetModuleSettings(ModuleId)"1"

 

If (Page.IsPostBack = False) Then

lblMessage.Text =

""

 

' get a list of repository modules on this portal

ddlRepositoryID.Items.Clear()

it +=

"2"

 

 

 

 

 

 

it +=

Dim repositories As New RepositoryControllerDim tabs As New TabControllerDim arrModules As New ArrayListDim objTab As TabInfoDim objModule As ModuleInfoDim objItem As ListItem"3"

arrModules = repositories.GetRepositoryModules(_portalSettings.PortalId)

it +=

"3a"

 

' Note this method is deprecated!

objTab = tabs.GetTab(objModule.TabID

it +=

For Each objModule In arrModules)"4"

 

If Not objTab Is Nothing Then

objItem =

objItem.Text = objTab.TabName &

it +=

New ListItem" / " & objModule.ModuleTitle"4a"

objItem.Value = objModule.ModuleID

ddlRepositoryID.Items.Add(objItem)

 

End If

 

Next

it +=

"5"

objItem =

objItem.Text =

New ListItem"Select Tab/Repository"

objItem.Value =

""

ddlRepositoryID.Items.Insert(0, objItem)

it +=

"6"

 

If CType(settings("repository"), String) <> "" Then

ddlRepositoryID.SelectedValue =

 

CInt(CType(settings("repository"), String))End If

it +=

"7"

 

If CType(settings("rowcount"), String) <> "" Then

txtRowCount.Text =

 

CType(settings("rowcount"), String)End If

it +=

"8"

 

If CType(settings("style"), String) <> "" Then

rbStyle.SelectedValue =

 

CType(settings("style"), String)End If

it +=

"9"

 

End If

 

Catch exc As Exception 'Module failed to load

ProcessModuleLoadException(it,

 

Me, exc, True)End Try

 

' Localization

rbStyle.Items(0).Text = Localization.GetString(

rbStyle.Items(1).Text = Localization.GetString(

rbStyle.Items(2).Text = Localization.GetString(

rbStyle.Items(3).Text = Localization.GetString(

rbStyle.Items(4).Text = Localization.GetString(

 

"CategoryListing", LocalResourceFile)"MultiColumnCategoryListing", LocalResourceFile)"LatestUploads", LocalResourceFile)"TopDownloads", LocalResourceFile)"TopRated", LocalResourceFile)End Sub

 

 

 

And by adding the check for  If Not objTab Is Nothing  then I think I have solved the problem :-)

Does anyone from the DNN Repository team want to look at including this in the main code?

 

 
New Post
9/13/2007 6:13 AM
 

Eeeek!

What happened to my lovely formatting???

In search of a nicer format... here's the code again, including the new If statement highlighted in Red.

        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            ' Obtain PortalSettings from Current Context
            Dim _portalSettings As PortalSettings = CType(HttpContext.Current.Items("PortalSettings"), PortalSettings)

            Dim it As String
            it = "Test text "
            Try

                ' Get settings from the database
                Dim settings As Hashtable = PortalSettings.GetModuleSettings(ModuleId)

                it += "1"

                If (Page.IsPostBack = False) Then
                    lblMessage.Text = ""
                    ' get a list of repository modules on this portal
                    ddlRepositoryID.Items.Clear()

                    it += "2"

                    Dim repositories As New RepositoryController
                    Dim tabs As New TabController
                    Dim arrModules As New ArrayList
                    Dim objTab As TabInfo
                    Dim objModule As ModuleInfo
                    Dim objItem As ListItem

                    it += "3"

                    arrModules = repositories.GetRepositoryModules(_portalSettings.PortalId)
                    it += "3a"

                    For Each objModule In arrModules
                        ' Note - this method is deprecated
                        objTab = tabs.GetTab(objModule.TabID)
                        it += "4"
                        ' Added this If statement to protect against Null References from dangling (homeless?) repositories
                        If Not objTab Is Nothing Then
                            objItem = New ListItem
                            objItem.Text = objTab.TabName & " / " & objModule.ModuleTitle
                            it += "4a"
                            objItem.Value = objModule.ModuleID
                            ddlRepositoryID.Items.Add(objItem)
                        End If
                    Next

                    it += "5"
                    objItem = New ListItem
                    objItem.Text = "Select Tab/Repository"
                    objItem.Value = ""
                    ddlRepositoryID.Items.Insert(0, objItem)

                    it += "6"

                    If CType(settings("repository"), String) <> "" Then
                        ddlRepositoryID.SelectedValue = CInt(CType(settings("repository"), String))
                    End If

                    it += "7"
                    If CType(settings("rowcount"), String) <> "" Then
                        txtRowCount.Text = CType(settings("rowcount"), String)
                    End If

                    it += "8"
                    If CType(settings("style"), String) <> "" Then
                        rbStyle.SelectedValue = CType(settings("style"), String)
                    End If

                    it += "9"
                End If
            Catch exc As Exception 'Module failed to load
                ProcessModuleLoadException(it, Me, exc, True)
            End Try

            ' Localization
            rbStyle.Items(0).Text = Localization.GetString("CategoryListing", LocalResourceFile)
            rbStyle.Items(1).Text = Localization.GetString("MultiColumnCategoryListing", LocalResourceFile)
            rbStyle.Items(2).Text = Localization.GetString("LatestUploads", LocalResourceFile)
            rbStyle.Items(3).Text = Localization.GetString("TopDownloads", LocalResourceFile)
            rbStyle.Items(4).Text = Localization.GetString("TopRated", LocalResourceFile)

        End Sub

 
New Post
9/13/2007 9:51 AM
 
Thanks! I've added your fix. It will be in the next release 3.01.14
 
New Post
9/13/2007 11:58 AM
 

You're welcome - thanks for all your work!

 

While you are there... you might also want to change the GetTab call to use the newer version (although I must admit I wasn't sure what the last parameter was really for!) 

objTab = tabs.GetTab(objModule.TabID, PortalSettings.PortalId, True)

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsRepositoryRepositoryDashboard - Object reference not set to an instance of an object.Dashboard - Object reference not set to an instance of an object.


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out