|
-
September 17th, 2004, 03:38 AM
#1
Object reference not set to an instance of an objec
Hallo,
I'm facing a strange error when trying to run a little code that normally must be correct. I port this code from c# to vb.net to get the website collection from a SharePoint Portal server.
Running the code get the error description that mentions that "Object reference not set to an instance of an object"
Follow here the code
Code:
Imports System
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Xml.Serialization
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.SPWeb
Imports Microsoft.SharePoint.Utilities
Imports Microsoft.SharePoint.WebPartPages
Imports System.Web.UI.HtmlControls
Imports Microsoft.SharePoint.WebControls
Imports System.Object
Private Sub sCompileTrail(ByVal objWeb As Microsoft.SharePoint.SPWeb)
If strTrail.Trim = vbNullString Then
If objWeb.IsRootWeb Then
strTrail = objWeb.Title
Else
strTrail = objWeb.Name
End If
Else
If objWeb.IsRootWeb Then
strTrail = "<a href=" & objWeb.Url & ">" & objWeb.Title & "</a> " & strTrail
Else
strTrail = "<a href=" & objWeb.Url & objWeb.Url.ToString & ">" & objWeb.Name & "</a> " & strTrail
End If
End If
If objWeb.ParentWeb.ToString <> vbNullString Then
sCompileTrail(objWeb.ParentWeb)
End If
End Sub
Public Function fGetWebTree() As String
Try
Dim objWeb As SPWeb = Microsoft.SharePoint.WebControls.SPControl.GetContextWeb(Context)
sCompileTrail(objWeb)
strTrail = strTrail & "1" & vbCrLf
If (objWeb.PortalUrl.Trim <> vbNullString) And (objWeb.PortalName.Trim <> vbNullString) Then
strTrail = "<a href=" & objWeb.PortalUrl & ">" & objWeb.PortalName() & "</a> " & strTrail
End If
Catch ex As Exception
strTrail = "Error! " & ex.Message
End Try
fGetWebTree = strTrail
End Function
the error occures on the "If objWeb.IsRootWeb" check from the sCompileTrail function.
Thanks in advance for your help
james
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|