Sorry for the poor title, it's really difficult to describe this issue. On my ASPX site, when a user clicks the button, I need to generate two new database items. I firstly need to create my User object, containing things such as email, password, and the UserID which is the primary key for that table. This has been working fine for a long time as it's pretty simple, and I've even set up some other tables with foreign keys referencing the User table (such as Images for Images uploaded by a user). Today I've been beginning to implement the Profile class, which will generate a default profile when a user registers.
The profile class takes 5 parameters to generate:
User user,
string TagLine,
string AboutMe,
string ProfilePhoto,
string ProfilePhotoExtension
Now you need not worry about the last 4 of those, the one I'm having trouble with is the User user. This takes a user class and acts as a foreign key to the User table's primary key (this is so I can retrieve information such as Username to put into the profile.)
Here's the snippet of code which is responsible for generating a new user, and then a profile based on that:
//Add user
var newUser = new BO.User(txtEmail.Text, newHashedPassword, txtUsername.Text);
//Create new profile
var newProfile = new BO.Profile(newUser, "This user has not yet set their tagline", "This user has not yet set their about me", "default", ".jpg");
db.UserAdd(newUser);
db.ProfileAdd(newProfile);
db.Save();
So as you can see I generate a new user class in the newUser variable, and then I try to use that variable to generate a new profile. I think that is the bit which is generating my error. After that I add and save them both to my database.
The error I'm getting is:
System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.NullReferenceException: Object reference not set to an instance of an object. at PiccyPic.BO.Profile..ctor(User user, String tagline, String aboutme, String profilephoto, String profilephotoextension) in c:\Visual Studios\PiccyPic\PiccyPic.BO\Profile.cs:line 37 at PiccyPic.Login.butRegister_Click(Object sender, EventArgs e) in c:\Visual Studios\PiccyPic\PiccyPic\Login.aspx.cs:line 134 at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.login_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\c03cf19f\4ceaa030\App_Web_mnmhlw3a.14.cs:line 0 at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Here's a screenshot of the debugging up to the point of when I get the error:

If you need any more information please ask for it, I'm not sure what would be helpful in solving this.