Possible Duplicate:
What is a NullReferenceException in .NET?
I'm having trouble deploying an asp.net .NET 4.5 website to a IIS 7 server running on Windows 2008 R2, which is running in a remote virtual machine. When I try to access a restricted member page in the virtual server in my machine(aka debuging in VS2012) it works perfectly, redirecting my to the login page in order for the user to log in and access the member page.
However, when I do the exact same thing in the website hosted in IIS7 I get the following error:
Server Error in '/WebApp' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
WebApp.Members.RedeSocial.Page_Load(Object sender, EventArgs e) +88
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772
I've researched the hell out of this and cannot find a solution to this. Any ideas? Thanks
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
namespace WebApp.Members
{
public partial class RedeSocial : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Service.Service1Client serv = new Service.Service1Client();
Library.Utilizador u = Library.Utilizador.loadByUsername(HttpContext.Current.User.Identity.Name);
dimRede.Text = serv.GetTamanhoRede(u.CODUTILIZADOR);
}
}
}