Login

Username

Password





Register   Reset password

This is a read-only archive of the forum.

# Constructor 5/1/2009 9:44 PM (edited 5/1/2009 10:28 PM)
If I do this:
                        
Template delTemplate = delsite.Templates[0] as Template;
this._templateService.DeleteTemplate(delTemplate);


or this:
                        
User delUser = this._userService.GetUserByUsernameAndEmail(username, email);
//Delete the user
this._userService.DeleteUser(delUser);

I get: System.NullReferenceException: Object reference not set to an instance of an object.


When in debug, I step through the operation and there is a template in 'delTemplate' and a user in 'delUser'. I get the same error for both.

Any ideas?

I will keep checking.

Just noticed in debug that there is a TemplateProxy:

delTemplate = {TemplateProxy46bce1d1a9484632b8be63cbd636c0f4}

How do I get the template I want to delete and delete it?
# martijnb 5/2/2009 10:23 AM
It shouldn't matter if you have a proxy or a real instance. What is the stacktrace of the exception?
# Constructor 5/2/2009 12:07 PM (edited 5/2/2009 12:11 PM)
[NullReferenceException: Object reference not set to an instance of an object.]
Cuyahoga.Modules.CatMod.Web.CatMod.BlitzSite(String username, String email, String sitename) +381
Cuyahoga.Modules.CatMod.Web.CatMod.btnBlitz_Click(Object sender, EventArgs e) +165
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565


I have been able to completely remove a site and its nodes and sections. Now I wish to remove the Template and the user that has been associated with the site. It is at this stage I get an error.

Has anyone created any SQL to remove a site instance completely?
# martijnb 5/3/2009 6:16 PM
You have probably checked it already, but something must be null in the code behind, looking at the stack trace. Maybe the services? Or is there an inner exception somewhere?
# Constructor 5/3/2009 6:33 PM
There is nothing null. I test by doing this:
Template delTemplate = delsite.Templates[0] as Template;
this._templateService.DeleteTemplate(delTemplate);

The delTemplate = {TemplateProxy46bce1d1a9484632b8be63cbd636c0f4} and still throws the System.NullReferenceException: Object reference not set to an instance of an object.

I have followed this back to where it deletes. Then it fails.
# martijnb 5/4/2009 5:30 PM
If you follow it back to where it deletes (CommonDao.DeleteObject?), is there something null over there? The session? Or CommonDao?
# Constructor 5/12/2009 10:22 PM (edited 5/13/2009 12:50 PM)
Solved
# martijnb 5/22/2009 1:04 PM
So, what was going wrong here?
# Constructor 5/22/2009 3:34 PM
martijnbSo, what was going wrong here?

I stripped out everything and coded it again. Then it worked.

The objects I was trying to delete had values (I could see them) but I was getting the same Null errors. So I cleanded everything out, performed a rebuild and coded again. Then it worked.

I believe it was me that was going wrong! I think that I may have had null '_templateService' or '_userService'. But it works now.

I have a rough module that accepts registrations with a site name, email address and template selection, creates a user, emails them login details and creates them a site based upon the template they selected.

I can also delete the user and site completely via admin. I am still not happy with it 100%. It leaves one or 2 orphan (unassigned) files.