0
votes

Hello i am getting this error message :

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:

Line 7:  
Line 8:      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Line 9:          UserIdValue.Text = Membership.GetUser().ProviderUserKey.ToString()
Line 10:         cannotUploadImageMessage.Visible = False
Line 11:     End Sub

can someone help me with this?

1
Seems Membership.GetUser() is null or Membership.GetUser().ProviderUserKey is null, just check for null. - Andrew Orsich
Or the controls cannotUploadImageMessage or UserIdValue do not exist at that stage. - slugster

1 Answers

0
votes

That's a pretty straightforward error to debug. The error message should tell you exactly which line it's on (either 9 or 10). It's just a matter of setting a breakpoint on that line and running the page, then working out which object hasn't been set by hovering your mouse over each object.