Category : Dasblog

Why blogging from Word 2007 to Dasblog does not work.

I was really excited by the Blogging feature Word 2007 – It looked really good, easy to use and some of the formats you can do to a picture are pretty cool.

As soon as I found it I tried to set it up with this dasBlog account – Word 2007 is supposed to support the metaWebLog API (which dasBlog supports from v1.9), so in theory it should have worked – however it didn’t work fully.
I could upload new blog posts but it didn’t like the posting of images – in returned a message saying it was not supported and I should use FTP upload instead.
I wasn’t happy with this as the metaWebLog API has a newMediaObject method which allows for uploading of images etc and I know it is implemented in dasBlog (I think Omar Shahine added it).


Anyway, I emailed Joe Friend (the MS guy who originally posted about this feature of Word) – he has since moved on so couldn’t help (in fact I think my email to him was the catalyst for his Email is now off post – oops)…

The annoying thing is that Windows Live Writer supports the metaWebLog API implemented by dasBlog and can upload images fine….

Mmmmm, something not right here – taking things into my own hands, I cracked open Fiddler and compared the HTTP request / responses between a Writer posting and a Word posting. The Word postings always fail on the newMediaObject calls – here is a screenshot of the request / response from Word.


Looks like Word is trying to pass the blogid parameter as an int and not as a string as the spec dictates…

As far as I know, Word works correctly with MySpaces, Blogger and a few other blogging engines – maybe they are not as strict as dasBlog when checking the parameter types passed ??

I suppose I could write an HTTPHandler or something to convert that type description from an ‘int’ to a ‘string’.

Windows Live Writer on Vista

One of the first apps I loaded onto my laptop (after paving it and installing Vista Ultimate) was Windows Live Writer (which I’m using to compose this post – on a plane at 38,000 ft on my way to Boston).

So it all installed OK, I ran it and it launches straight into the config wizard (setting up your blogs) – I entered my site, username and password and hit next… Bang it fails – apparently it timed out.

OK, maybe the wrong password or something – reenter it – same thing…

Check the website is working – Yes.

Run this same config on my WinXp machine – Works OK ???

Lets look at the logging – seems to be found at :

C:Users%USERNAME%AppDataLocalWindows Live WriterWindows Live Writer.log

This gives me an error message as follows :-


WindowsLiveWriter,1.2012,None,00001,27-Nov-2006 11:32:13.063,”Unexpected exception occurred while processing resource Providers.BlogProvidersB2.xml: System.Xml.XmlException: ‘–‘ is an unexpected token. The expected token is ‘>’. Line 31, position 3.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.DtdParserProxy.System.Xml.IDtdParserAdapter.Throw(Exception e)
at System.Xml.DtdParser.Throw(Int32 curPos, String res, String[] args)
at System.Xml.DtdParser.ThrowUnexpectedToken(Int32 pos, String expectedToken1, String expectedToken2)
at System.Xml.DtdParser.ScanClosingTag()
at System.Xml.DtdParser.GetToken(Boolean needWhiteSpace)
at System.Xml.DtdParser.ParseEntityDecl()
at System.Xml.DtdParser.ParseSubset()
at System.Xml.DtdParser.ParseExternalSubset()
at System.Xml.DtdParser.ParseInDocumentDtd(Boolean saveInternalSubset)
at System.Xml.DtdParser.Parse(Boolean saveInternalSubset)
at System.Xml.XmlTextReaderImpl.ParseDoctypeDecl()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.Load(Stream inStream)
at WindowsLive.Writer.BlogClient.Providers.BlogProviderManager.ReadXmlBlogProviders(Stream blogProviders)
at WindowsLive.Writer.CoreServices.ResourceFileDownloader.ProcessResourceSafely(String name, String resourceUrl, Int32 requiredFreshnessDays, Int32 timeoutMs, ResourceFileProcessor processor)”,””

Looks like there is a error in the XML somewhere, so I pull my feed and validate it – looks like valid RSS2.0.

Turn OFF Vista’s crazy (and plain annoying) Use Account Control (UAC) – the source for all the ‘grey screens of iritation’ I get when trying to do ANYTHING – No change.

OK, it’s trying to get config data from/for me right ? – I have that config data on my desktop (WinXP) already so lets just copy it over. Examine the WinXP desktop for the config data – find it in the registry under : HKEY_CURRENT_USERSoftwareWindows Live Writer : a whole raft of reg keys.

Export the whole shebang – merge it into the Vists machines registry – rerun Writer – all the config data is in there (excellent I can now post) !!

Copy the reg setings away to another drive in case I have to pave the machine again.

Dasblog – Daily Activity Report

One of my gripes with dasBlog is the reporting. To get to reports I have to browse to my blog, login and then view the reports online – bit of a pain doing this every day (yes I am so vain that I like to see my stats on a daily basis).

So I spent a few hours recently adding an ‘Daily Activity Report’ feature.  It was surprising easy – checkout (get a working copy) of the source from sourceforge (browse it here, familiarize yourself with it, add your changes and create a patch. Send the patch to someone with admin rights (so it can be checked in) and that’s it… I’d recommend to anyone to try it out…

Anyway the ‘Daily Activity Report’ feature – basically starts a background thread which caches the current date and then ticks every hour. Each tick it will check the current date against the cached date and if they do not match then it will send an email to either the Notification list or the Site Owner / Administrator. It is configured by simply checking a box in the configuration page (in the SMTP Server section)

The email contains similar detail to that of the ‘Activity… Referrers’ page.

I also made the method / class that implements the creating / sending the report public so that it can be extended – I was thinking along the lines of a ‘Send Daily Activity Report Now’ button or enhancing the Mail-To-Weblog to monitor for a specific phrase in the subject and if found to send the report (maybe also specify the date)…

Watch this space for updates…

Dasblog Macros – Code

Here’s the code for the macros I created – feel free to copy / compile it yourself. I also included a compiled DLL here – BUT it is compiled against .NET2.0 so will only work if your hosting Dasblog in a ASP.NET2.0 virtual directory.

  • Copy the compiled DLL into your /bin folder
  • Edit your Web.config file, locate the <newtelligence.DasBlog.Macros> node
  • Add the following element <add macro=”khmacros” type=”KensDasblogMacros.KensMacros, KensMacros”/>
  • Edit your template pages to include <%TrackbackCount()|khmacros%> or <%TrackbackountAll()|khmacros%> or <%KensBlogStats()|khmacros%>

using System;

using System.Collections;

using System.Text;

using System.Web.UI;

using newtelligence.DasBlog.Runtime;

using newtelligence.DasBlog.Web.Core;

using newtelligence.DasBlog.Util;



namespace KensDasblogMacros


    public class KensMacros



        protected SharedBasePage sharedBasePage;

        protected Entry currentEntry;


        public KensMacros(SharedBasePage page, Entry entry)


            sharedBasePage = page;

            currentEntry = entry;



        public virtual Control TrackbackCount()


            if (this.currentEntry != null)


                int trackbackCount = 0;

                IBlogDataService dataService = sharedBasePage.DataService;

                trackbackCount = dataService.GetTrackingsFor(currentEntry.EntryId).Count;

                return new LiteralControl(trackbackCount.ToString());


            return new LiteralControl(“”);



        public virtual Control TrackbackCountAll()


            int trackbackCountAll = 0;


            IBlogDataService dataService = sharedBasePage.DataService;

            DateTime[] daysWithEntries = dataService.GetDaysWithEntries(UTCTimeZone.CurrentTimeZone);


            foreach (DateTime day in daysWithEntries)


                EntryCollection entries = dataService.GetEntriesForDay(day, UTCTimeZone.CurrentTimeZone, String.Empty, 1, int.MaxValue, String.Empty);

                foreach (Entry potentialEntry in entries)


                    trackbackCountAll += dataService.GetTrackingsFor(potentialEntry.EntryId).Count;


                return new LiteralControl(trackbackCountAll.ToString());


            return new LiteralControl(“”);



        public virtual Control KensBlogStats()


            StringBuilder sb = new StringBuilder(




                IBlogDataService dataService = sharedBasePage.DataService;


                DateTime monthFirst = new DateTime((DateTime.UtcNow.Year), (DateTime.UtcNow.Month), 1, 0, 0, 0);

                DateTime monthLast = new DateTime((DateTime.UtcNow.Year), (DateTime.UtcNow.Month), DateTime.DaysInMonth(DateTime.UtcNow.Year,DateTime.UtcNow.Month),23,59,59);


                DateTime weekFirst = Macros.GetStartOfCurrentWeek();

                DateTime weekLast = Macros.GetEndOfCurrentWeek();


                DateTime yearFirst = Macros.GetStartOfYear(DateTime.UtcNow.Year);

                DateTime yearLast = Macros.GetEndOfYear(DateTime.UtcNow.Year);


                int allEntriesCount = 0;

                int yearPostCount = 0;

                int weekPostCount = 0;

                int monthPostCount = 0;

                int trackbackCount = 0;

                DateTime[] daysWithEntries = dataService.GetDaysWithEntries(newtelligence.DasBlog.Util.UTCTimeZone.CurrentTimeZone);

                foreach (DateTime day in daysWithEntries)


                    EntryCollection entries = dataService.GetEntriesForDay(day, newtelligence.DasBlog.Util.UTCTimeZone.CurrentTimeZone, String.Empty, 1, int.MaxValue, String.Empty);

                    allEntriesCount += entries.Count;

                    foreach (Entry potentialEntry in entries)


                        if (potentialEntry.CreatedUtc > monthFirst && potentialEntry.CreatedUtc <= monthLast)





                        if (potentialEntry.CreatedUtc > weekFirst && potentialEntry.CreatedUtc <= weekLast)





                        if (potentialEntry.CreatedUtc > yearFirst && potentialEntry.CreatedUtc <= yearLast)





                        trackbackCount += dataService.GetTrackingsFor(potentialEntry.EntryId).Count;




                int commentCount = dataService.GetAllComments().Count;


                sb.Append(“<div class=”blogStats”>”);

                sb.Append(“<table border=”0″ width=”100%”>”);

                sb.Append(“<tr><td align=”left”>Total Posts</td><td align=”right”>” + allEntriesCount + “</td></tr>”);

                sb.Append(“<tr><td align=”left”>This Year</td><td align=”right”>” + yearPostCount + “</tr></td>”);

                sb.Append(“<tr><td align=”left”>This Month</td><td align=”right”>” + monthPostCount + “</tr></td>”);

                sb.Append(“<tr><td align=”left”>This Week</td><td align=”right”>” + weekPostCount + “</tr></td>”);

                sb.Append(“<tr><td align=”left”>Comments</td><td align=”right”>” + commentCount + “</tr></td>”);

                sb.Append(“<tr><td align=”left”>Trackbacks</td><td align=”right”>” + trackbackCount + “</tr></td>”);




            catch (Exception ex)


                sharedBasePage.LoggingService.AddEvent(new EventDataItem(EventCodes.Error, “KensBlogStats Error: “ + ex.ToString(), String.Empty));


            return new LiteralControl(sb.ToString());







Dasblog Macros

So, having recently updated this website to Dasblog 1.9, I decided it was time to check out the source and have a play around.

The initial easy step to get involved seemed to be writing some Macros (I wanted to extend the default blogStats() macro to include Total Trackbacks and also add a Trackback Count to each post item in the footer.

There is a great intro to Creating Dasblog Macros on their Documentation Site, also googling for Dasblog macros uncovered a few good sites

Anyway, I cracked open VS and spent a couple of hours writing some new macros, compiled them, made the requisite changes to my homeTemplate and itemTemplate but they just seemed to be return null strings. Checking the (Dasblog) event log showed that it was failing the find the Type for my Macros.

I checked and rechecked everything and was convinced that everything was as it should be. Stumped!!
Viewed my DLL in reflector, typenames were all correct – what was I doing wrong ??

A quick post to the Dasblog developers mailing list resulted in someone suggesting that I check if I was running a .NET2 compiled DLL in a .Net1.1 IIS virtual directory – Doh !!

Updated the virtual directory to ASP.NET 2.0 (easier than reverting to VS2003 from VS2005), ‘touched’ the web.config, refreshed the page and ‘ta da…’

Changes and source code to be rolled out to this web site in the next day or so (more testing to do on how ASP.NET 2.0 works out),