473,382 Members | 1,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Need help Web Application VS 2005

1
I'm trying to debug the following code against a moss 2007 portal, using vs 2005. It's a web application with an .aspx page that contains a label, a text box and a button. The user writes a user account in the text box and on button click the groups for the user are returned. The error that it appears is
'An exception of type 'System.NullReferenceException' occurred in WebApplication2.DLL but was not handled in user code

Additional information: Object reference not set to an instance of an object'

highlighting the code line:
SPWebCollection allSites = mySite.AllWebs;
The whole code follows:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.Utilities;

namespace WebApplication2
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

protected void Button1_Click(object sender, EventArgs e)
{
string userList = TextBox1.Text + " is a user in the following webs:<br>";

SPSite mySite = SPControl.GetContextSite(Context);
SPWebCollection allSites = mySite.AllWebs;

foreach (SPWeb subSite in allSites)
{
string listGroups = "";

SPUserCollection allUsers = subSite.Users;

foreach (SPUser user in allUsers)
{
if (user.LoginName == TextBox1.Text)
{
SPRoleCollection allGroups = user.Roles;
foreach (SPRole group in allGroups)
{
listGroups += SPEncode.HtmlEncode(group.Name) + " ";
}

userList += subSite.ServerRelativeUrl.ToString() + " -- " + listGroups + "<BR>";
}
}
}

Label1.Text = userList;
}
}
}


Any suggestions would be more than welcomed...
Jan 15 '07 #1
0 1201

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Dmitry Demchuk | last post by:
Hi everybody. Recently I ran into situation with System.Threading.Timer in my ASP.NET application. I reinstalled Windows on one of my servers and got timers stop firing events after while, they...
5
by: Mike Owen | last post by:
Hi, I have just used the import Wizard to import a VS 2003 app to VS 2005. I have a lot of work to do to enable it to compile successfully with all the errors and warnings it gave me, but as a...
3
by: ChrisWinterscheid | last post by:
We are running DB2 8.1 on AIX 5.2. DB2level shows: DB21085I Instance "db2inst1" uses "32" bits and DB2 code release "SQL08016" with level identifier "02070106". Informational tokens are "DB2...
3
by: fayez | last post by:
Hi. I have a sql Stored Procedure running on aix5.1, db2 udb 8.1.2 it has a temp table, but when it's done running it does not free heap memory, here is a snapshot of db2diag.log which becomes...
1
by: Likhith Areekkal | last post by:
Hi, My background: Passed Bachelors in Computer Science 2 years back with distinction in Canada. Had to do survival jobs for 2 years as the comp. industry was in bad shape. Serious about...
0
by: Mart | last post by:
Hi, I have just written (my first) VB.net app using MS Visual Basic 2005 Express Edition Beta. It is fairly simple, it reads some configuration data from an XML file then opens a new window...
21
by: nihad.nasim | last post by:
Hi there, I have a database in Access that I need on the web. The web page should connect to the database and write records for certain tables and view records for others. I want to know a...
9
by: Algonquin J. Calhoun | last post by:
I've developed an application that exceeds the Access 2GB limit. This application was developed as a prototype and the users have found it very useful. Approximately 45,000 records are added to...
11
by: cj | last post by:
I have used web services before WSDL files and such but never written one. I need some basic starting info. 1. Can I write a web service in a windows app? or are all web services asp web...
0
by: rmgalante | last post by:
I was developing a large web site in VS 2005 as a web site project. I was having problems with the VS 2005 publish tool. It was slow, and provided no feedback. It has other issues as outlined...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.