Error while using sharepoint dll's

chime

Member
Joined
Jul 12, 2005
Messages
22
Location
wexford, Ireland
Programming Experience
3-5
Hi

I hope there is someone out there who can help me this error on my project.
This is the first time I am trying to integerate sharepoint and vb.

I am trying to use the following sharepoint dll's in my project.
Microsoft.SharePoint.Security.dll
Microsoft.SharePoint.Dsp.dll
Microsoft.SharePoint.Library.dll

I have added them to my project as references and included them in my project.
I am developing on a test area on the server 2003


My code is as follows

VB.NET:
[SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][SIZE=2] System.Data
[/SIZE][SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][SIZE=2] System.Data.SqlClient
[/SIZE][SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][SIZE=2] System.Configuration
[/SIZE][SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][SIZE=2] Microsoft.SharePoint
[/SIZE][SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][SIZE=2] Microsoft.SharePoint.WebControls
[/SIZE][SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][SIZE=2] Microsoft.SharePoint.Utilities[/SIZE]
 
[SIZE=2]...[/SIZE]
 
[SIZE=2]
[/SIZE]Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
Dim userList As String = SPEncode.HtmlEncode("Textbox1.text") & " is a user in the following webs:<BR>"
Dim mySite As SPSite = SPControl.GetContextSite(Context)
Dim allSites As SPWebCollection = mySite.AllWebs
Dim subSite As SPWeb
Dim strTestUser As String
 
Try
 
strTestUserName = subSite.CurrentUser.Name
strTestUserLogin = subSite.CurrentUser.LoginName
strTestUserID = subSite.CurrentUser.ID.ToString
 
 
For Each subSite In allSites
Dim listGroups As String = ""
Dim allUsers As SPUserCollection = subSite.Users
Dim user As SPUser
For Each user In allUsers
If user.LoginName = strTestUser Then
Dim allGroups As SPRoleCollection = user.Roles
Dim group As SPRole
For Each group In allGroups
listGroups += SPEncode.HtmlEncode(group.Name) & " "
Next group
userList += subSite.ServerRelativeUrl.ToString() & " :: " & listGroups & "<BR>"
End If
Next user
Next subSite
 
Catch ex As Exception
End Try
 
 
End Sub



The try catch error I am getting is
Message "Object reference not set to an instance of an object."
It occurs on
Dim allSites As SPWebCollection = mySite.AllWebs
and gives this error
<error: an exception of type: {System.Runtime.InteropServices.COMException} occurred> Date



More output from the
SPControl.GetContextSite(Context) is in the attached word document.


I would really appreciate any help that anyone can give me on this.

Thanks in advance

chime
 

Attachments

  • error.doc
    70.5 KB · Views: 23
Last edited:
Back
Top