XML Parsing Error when adding a category - Now blog not appearing

Apr 3, 2009 at 6:51 AM
Edited Apr 3, 2009 at 8:27 AM
I thought I would add a category to my blog as it currently does not have one.

I tried to add a category by going into categories while signed on. I then added a Title and description for the category and clicked on Add Category.

No Category appeared so I tried signing in again and updated the category by giving its Parent name (which previously said none) the same name as the Title of the category. I then clicked Update and the following error appeared

XML Parsing Error: no element found
Location: http://www......com ( *I think the location was in the categories.aspx.cs file, not sure*)
Line Number 1, Column 1:

Im now unable to access my website. It just says

The page cannot be displayed


The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings.

I tried deleting all cookies, restarting my computer etc. I still cannot access my website which has blogengine.net running on it.

I then tried doing the same on my PC running blogengine.net on visual studio 2005 and the following error appeared.


WebDeve.WebServer.exe has encountered a problem and needs to close. Now the blog has stopped running on my PC as well.

What concerning is that this error is permanent. I cannot get it to go away even after restarting visual studio. So Im worried i have lost everything and will have to reinstall blogengine.net.

This is a wild guess but mabye it is caught in some sort of infinite loop. If someone could provide some code and tell me exactly where to place it to both stop the error and prevent it from re-occuring this would be appreciated.

Apr 3, 2009 at 8:29 AM
Edited Apr 3, 2009 at 9:20 AM
This is weird. I tried doing some debugging by placing various breakpoints in the categories.aspx.cs file.

When I ran the application a window appeared titled “Find Source: Category.cs

This window shows a list of my documents in the My Documents folder.

The File name it is looking for is the following

C:\Documents and Settings\Mads Kristensen\Dokumenter\Visual Studio 2005\Projects\BlogEngine.NET\DotNetSlave.BusinessLogic\Category

The above path and directories do not exist on my PC. It appears it is looking for a file that exists on someone else’s hard drive with one of the parent folders named "Mads Kristensen".
Apr 3, 2009 at 6:11 PM
What version of BE are you using?  Do you also have the BE Core code loaded in Visual Studio -- or just the website project?

You might have a breakpoint set and are trying to Step-into the core code.  If you have both the Core code and the website project loaded in VS, then this error probably won't occur.  But, if you have just the website project loaded, this could be the problem.  You could try deleting the PDB and XML files from your BIN directory (so just the DLL file remains).  This might remove debug information about the BE Core that isn't needed and is causing VS to look for a location that doesn't exist on your computer (re-start VS after doing this).
Apr 3, 2009 at 8:15 PM
Edited Apr 3, 2009 at 9:55 PM
I have blogengine.net 1.4.5. The latest version which I downloaded a few days ago. The application is 1239K and includes the Bin folder which contains 3 files.  Blogengine.Core.Dll, Blogengine.Core.PDB, blogengine.Core.XML
Not sure what you mean by BE Core code loaded in Visual Studio . I just downloaded the entire application from the site and ran it from visual studio 2005 . It worked first time and I was impressed. I published ALL the files by selecting “Build” – “Publish Web site” and then uploaded all of the files to my shared web hosting account online. Everything worked well and I added some posts.
There must be a critical bug in the application because all I did was try and add a category. I added 1 Category with a title “Mind Map”. I noticed that the Title had not appeared on the right hand side of the blog so I logged back in, went to categories and If I can remember correctly I clicked on Edit or update for the category I just added. The parent of that category was set to “none”. I selected the dropdownlist under parent and to my surprise “Mind Map” was listed as a parent item in the dropdownlist even though I hadn’t added a parent. I selected “Mind Map” for the parent which meant that the title of the category and the parent of that category had the same name ((which perhaps shouldn’t be possible). I then saved the changes. It was at this point that the error occurred that I explained in my first post.
My site is still down which means it wont be indexed by the search engines. A common “Page not found” error appears.
I tried running the application in Visual studio. It worked like it did online until I tried to add a category again and then everything is still down on my PC as well.
I did what you said and removed those files and restarted VS.NET.
Unfortunately this has not resolved the problem. I still keep getting the same error message. Even if it did temporarily fix the error it could reappear again later.
WebDeve.WebServer.exe has encountered a problem and needs to close. Now the blog has stopped running on my PC as well.
If you could help me resolve this error it would be much appreciated as I need to get this blog up and running as soon as possible.
Apr 3, 2009 at 10:13 PM
Edited Apr 3, 2009 at 10:14 PM
After you do the Build -> Publish in VS, in the folder you published to, are there extra files in the BIN directory -- other than the 3 files you started with?

Usually, in VS, when you do a Build -> Publish, it pre-compiles the code files into one or more DLL files.  This has caused problems for other people too.  It should work though if you just copy all the BE files to the destination folder, or FTP site -- without using the Publish feature in VS.
Apr 3, 2009 at 11:24 PM
I understand what you said about not publishing the files to the remote server. Just copy the files.
However I do not see how that has anything to do with the site not working on Visual studio 2005 on my own pc when I update a category.

Before the error appeared I copied all the latest blogengine files from the dotnetblogengine site to vb 2005 on my own pc so there should not be any files missing or corrupt.

Just to make sure I deleted the 3 files in the bin directory and replaced them with the 3 files from the source site. Still I get the same error.

I have not altered any code from the original files. Only <h1> <h2> tags from the CSS file.

Im going to download the latest version of blogengine again and run them in visual studio 2005 and then update the category to see if the same errors appear.

It means i loose all my posts but at least it will make sure no files have been corrupted.


Apr 3, 2009 at 11:51 PM
Edited Apr 4, 2009 at 3:11 AM
I downloaded the files again. This time BlogEngine.NET 1.4.5 (source) I made sure i had the BlogEngine.Core folder/files within the project when i opened it up.

Unfortunately i still get the same error as soon as i try and update the categories in visual studio 2005 on my PC.

I also downloaded BlogEngine.NET 1.4.5 (web) folder. I un-selected readonly in properties for the root folder and the App_Code folder.

I deleted all my files on my hosting server (discount.asp) which supports asp.net 2.0 . I then used FTP to upload all the files to the server without changing anything and without using Build > Publish.

The same error appears. I've spent most of the day trying to fix this but i guess it must be an error deep within the code itself. Im suprised more people aren't experiencing it.

Whats annoying is that this bug cannot be reversed. The error appears whenever i try to run the project and the only way of getting rid of the error is starting afresh with the original downloaded files.

Apr 4, 2009 at 6:25 AM
Couple of things ...

After you add a category, check the categories.xml file in the App_Data folder to see if the new category shows up in that file.  If the new category doesn't show up in the categories.xml file, then you might want to make sure you have Write permissions setup for the ASPNET account for the App_Data folder (or Network Service account on Windows Server OS).  Then again, if you can save Posts, then you probably do have Write permissions on the App_Data folder already setup.

If after adding a category, you don't see it in the categories list (or wherever you're not seeing it), I'm guessing it's not getting correctly saved.

When the error occurs, you probably don't need to re-copy (or re-FTP) the files over again.  Just re-starting the blog application might stop the error from occurring.  You could re-start the blog application by re-uploading your Web.config file, or making a small change to the Web.config file (add a space to it, etc).

Since you've got Visual Studio, you could download one of the recent changesets on the Source Code above and trying using that version.  The BlogEngine core project needs to be compiled into a DLL if you download one of the recent builds on the Source Code tab.  Since BE 1.4.5 was a August 2008 release and there's been quite a number of changes to BE (including some category related changes), it's possible you won't have this problem with the recent builds.
Apr 4, 2009 at 2:14 PM
Edited Apr 4, 2009 at 9:02 PM
Replacing the web.config file does not work in preventing the error from appearing when re-loading. However deleting the new category which causes the error in the App_Data/categories.xml file does work.

I un-selected readonly in properties for the root folder and the App_Code folder so it has write permissions

The new category does appear in App_Data/categories.xml but does not appear on the blog page under Category List.

This is what it looks like:


    <category id="19770e74-9ec9-4cde-b2ab-e5051aaaf348" description="Posts about my adventures with BlogEngine.NET" parent="">BlogEngine.NET</category>

<category id="1ae8bee9-c6ea-4e50-ad41-69c97f9e18ed" description="My Article about the Environment" parent="1ae8bee9-c6ea-4e50-ad41-69c97f9e18ed">The Environment</category>

If you notice the category id is the same as the parent. They are both 1ae8bee9-c6ea-4e50-ad41-69c97f9e18ed.

When I have no parent for the second category the blog runs but the new category still does not appear.
I tried downloading the later updates but cannot run them as they were created for visual studio 2008. Im not sure which folders to copy or replace so I can run them in visual studio 2005.
I downloaded the latest changeset (18133 ) created for visual studio 2005.
Tried running it as a project. It says:

The source control provider associated with this solution could not be found. the projects will be treated as not under source control.

Do you want to permanently remove the source control bindings from this projects?

I chose yes.

I’ve read that this message can be caused by using VS Standard rather then the professional version.
Then I get the following message.
One or more projects in the solution could not be loaded for the following reason(s)
The project file or web has been moved, renamed or is not on your computer.

These projects will be labelled as unavailable in Solution Explorer. Expand the project node to show the reason the project could not be loaded.

I copied over the files in my version with some of the files in this changeset. Now the blog does run when I add a new category but it does not appear under the Category List on the blog. Yet it still appears in the category.xml file.

I’ve spent about 2 days trying to get this to work. I don’t think im going to have any luck. I suppose I could use the blog without adding categories but this will limit the blog quite a bit.
Apr 4, 2009 at 6:31 PM
I opened up the SLN file from changeset 18133 in VS 2005 Professional.  I received the same warnings/messages about the source control provider and project not being able to load.  After opening it, in Solution Explorer, I can see the BE Core project loaded up, but the Web project shows as being "unavailable" -- because it can't be found.  Here's the steps I took to get the solution back together.

1. Right-click on that unavailable project and select 'Remove'.

2. Only the BE Core project remains in the solution.  I then right-click on the BlogEngine solution in solution explorer, and select 'Add' -> Existing website.  I select the BlogEngine.NET folder within changeset 18133.

3. I then right-click on the website I just added in solution explorer and choose 'Set as StartUp Project'.

4. I then right-click on the same website in solution explorer, and choose Property Pages.

5. On the References tab, I click 'Add Reference...'.  In the Add Reference window that comes up, I select the Projects tab.  There's one project already in there -- BlogEngine.Core, from the 18133 changeset.  If you don't see that, going to the Browse tab should allow you to find the select the BlogEngine.Core project for changeset 18133.  I select OK.  In the list of References, BlogEngine.Core now shows up with a "Type" of Project and a "Version" of Auto Update.  Click OK.

I can now build the entire solution and run it.  When building the solution, the BlogEngine core DLL file automatically gets put into the BIN folder of the website because of the project reference added in step 5 above.

******** PART 2 of this MESSAGE ********

After all the setup described above, I ran BE in Visual Studio.  I was able to add categories without any errors.  In the categories.xml file, here's an example of one of the categories:

<category id="2710a9ef-03fe-47ea-a371-55a83193ca49" description="" parent="">test 1</category>

I didn't assign any parent to the category.

After adding a couple of categories, they DID NOT show up in the categories list.  This is because it appears only categories tied to posts show up in that list.  Meaning, if you add a post and select the new category you added, then that category will start showing up in the category list.

I'm not sure how you ended up with a category in the categories.xml file that has the same category id and parent id in the same line.  If you can get the Visual Studio project setup correctly, you can put a breakpoint in the UpdateCategory and InsertCategory methods in the Categories.cs file in the Providers\XmlProvider folder within the BE core project.  This might help you understand where these values are coming from.
Apr 4, 2009 at 9:03 PM
Edited Apr 4, 2009 at 11:58 PM
Im sorry but im unable to follow your instructions.
You said
2…..right-click on the BlogEngine solution in solution explorer, and select 'Add' -> Existing website.  I select the BlogEngine.NET folder within changeset 18133.
There is no Add > Existing website only Add > existing Item. And this does not enable me to select a folder.
3. I then right-click on the website I just added in solution explorer and choose 'Set as StartUp Project'.
There is no option to ‘Set as StartUp Project’.
Is it possible you could just send me a working version of the blog for vs.net 2005 standard,  via email. This may solve everything and save time.
I noticed other people are having similar problems to myself. For example the following post: http://www.codeplex.com/blogengine/Thread/View.aspx?ThreadId=36081
However I tried following the instructions meantioned in the above link and that still did not resolve the problems.
Apr 4, 2009 at 9:38 PM
I just sent an email to you.

If you open up the SLN file, then in Solution Explorer, right-clicking on the Project (not solution) would give you options such as "Add -> Existing Item" etc.  But, above the project in solution explorer, there should be a solution (the very top node in the treeview).  That top node should say:

Solution 'BlogEngine' (1 project)

After adding the website project, that line will say ...

Solution 'BlogEngine' (2 projecs)

The idea is that you have a single solution with 2 projects in it.  1 project is the BE Core, and ther other project is the website project.

Anyhow, hopefully you'll have better luck with the file I sent you.  The file I sent you should actually already have the solution setup correctly -- so you won't (or shouldn't) need to follow those steps I outlined.
Apr 5, 2009 at 8:11 AM
Edited Apr 5, 2009 at 8:11 AM
Thank you for sending me the file.
I can now add categories but the error still occurs under the categories option.
For example I noticed in the control Panel under categories you have already added a Category Name/Title called “test 1”.
Now if I was to select edit for test 1 and then select the dropdownlist under parent for that category (test 1),   there would be 3 Options.
1, None,
2. Blogengine.Net and
3. test 1
If I was then to select “test 1” in the dropdownlist (under parent) for the category “test 1” and press update . Then go to the front page the blogengine crashes and cannot be restarted unless you delete the new category from App_Data/Categories/xml .
This is NOT a major error if you now how to fix it but it still caused me a lot of confusion. I don’t understand how a category can become a child of itself.
I will still use blogengine.net as it is great for creating blogs.
Apr 5, 2009 at 6:15 PM
Why are you trying to assign a parent category of "test 1" for the category "test 1"?  It also crashes for me too.  BE should prevent someone from doing this since it doesn't make sense ... but since it doesn't make sense to make a category be its own parent category, it shouldn't be done even though it's a choice in the dropdown list.

This can be avoided by not including the (self) category in the dropdown list.  In the Categories.aspx.cs file in the admin\Pages folder, change the LoadParentDropDown to this:

private void LoadParentDropDown(DropDownList ddl, Category self)
    // Load up the Parent DropDown
    ddl.Items.Add(new ListItem("none", "0"));
    foreach (Category cat in Category.Categories)
        if (self == null || !cat.Id.Equals(self.Id))
            ddl.Items.Add(new ListItem(cat.CompleteTitle(), cat.Id.ToString()));

Then change the grid_RowDataBound event handler to this:

void grid_RowDataBound(object sender, GridViewRowEventArgs e)
    if (e.Row.RowState == DataControlRowState.Edit ||
            e.Row.RowState == (DataControlRowState.Alternate | DataControlRowState.Edit))
        Category self = (Category)e.Row.DataItem;
        DropDownList ddlParent = (DropDownList)e.Row.FindControl("ddlParent");

        LoadParentDropDown(ddlParent, self);
        if (self.Parent != null)
            foreach (ListItem item in ddlParent.Items)
                if (item.Value == self.Parent.ToString())
                    item.Selected = true;

Lastly, in the Page_Load event, add "null" as a second parameter to the call to LoadParentDropDown ...

LoadParentDropDown(ddlNewParent, null);
Apr 5, 2009 at 11:08 PM
Edited Apr 6, 2009 at 12:11 AM
Thank you for sending me a more recent version.
I’ve noticed a small bug which changes the titles of each entry.
If you go to  Settings > Themes > Indigo
So that the new theme is Indigo
Then you add a new Entry
If you insert a title for the new entry the text of the title includes + signs rather then spaces between each word.
Do you have the code to fix this so i can add new entries.
Thank you
Apr 5, 2009 at 11:29 PM
That's interesting.  I sort of recall someone maybe pointing this out before, but not sure.

Anyways, the fix is to go into the PostView.ascx file in the Indigo theme folder.  Currently, you'll find this code:

<a class="postheader taggedlink" href="<%=Post.RelativeLink %>"><%=Server.UrlEncode(Post.Title) %></a>

Change that so it uses HtmlEncode instead of UrlEncode, like this:

<a class="postheader taggedlink" href="<%=Post.RelativeLink %>"><%=Server.HtmlEncode(Post.Title) %></a>
Apr 6, 2009 at 1:39 AM
Thanks for that.

Just one more thing. I was unable to delete the pages awhile ago when clicking delete due to a Javascript problem. You provided me code to prevent the Confirm Delete Message box from appearing and this solved the problem. Now i can delete the pages.

I tried to implement the same change elsewhere so i can delete posts on the home page and on the page of the post itself. However i cannot find these lines of code.

What other code do i need to change so the confirm delete message box does not appear when deleting a post, comment ect.

Thanks for all your help

Apr 6, 2009 at 4:09 AM
For deleting comments, in the BE core code, in the Web\Controls folder is a CommentViewBase.cs file.  Within that, there's an "AdminLinks" property.  For the line below:

sb.AppendFormat(" | <a href=\"javascript:void(0);\" onclick=\"if (confirm('{1}?')) location.href='?deletecomment={0}'\">{2}</a>", Comment.Id, confirmDelete, page.Translate("delete"));

Change that line to:

sb.AppendFormat(" | <a href=\"?deletecomment={0}\">{1}</a>", Comment.Id, page.Translate("delete"));


For deleting posts, in the BE core code, in the Web\Controls folder is a PostViewBase.cs file.  Within that's there's an "AdminLinks" property.  For the line below:

sb.AppendFormat(CultureInfo.InvariantCulture, "<a href=\"javascript:void(0);\" onclick=\"if (confirm('{2}')) location.href='{0}?deletepost={1}'\">{3}</a> | ", Post.RelativeLink, Post.Id.ToString(), confirmDelete, page.Translate("delete"));

Change that line to:

sb.AppendFormat(CultureInfo.InvariantCulture, "<a href=\"{0}?deletepost={1}\">{2}</a> | ", Post.RelativeLink, Post.Id.ToString(), page.Translate("delete"));


After that, you'll want to build the BE core project.  In VS, Build -> Build Solution.  This will produce a new DLL for your BIN folder.
Apr 6, 2009 at 2:38 PM
Thanks for everything.

Im creating this blog using blogengine.net partly because i want to include affiliate links and advertisers in the blog, Preferably at the side of the blog.

Does the Blogengine version you gave me (18133 for vs 2005) support an easy method of adding affiliate links and banners at the side of the blog or must i obtain a later version?

Apr 6, 2009 at 5:14 PM
You should be able to do everything with 18133.  You can add links using widgets -- such as the LinkList widget or TextBox widget.  You could also edit the site.master file in the theme folder and add HTML markup in there too.