Dec 13, 2009 at 3:28 PM
Edited Dec 13, 2009 at 3:29 PM
I'm trying to write a custom converter to convert my old xhtml files into BlogEngine.NET posts. I was going to use the "Post" class from the core class library, but I've stumbled over an issue I can't seem to resolve.
My code is roughly this:
Post newsPost = new Post();
newsPost.Author = "Marc Scheuner";
newsPost.DateCreated = DateTime.Parse(effectiveDate, swissGerman);
//newsPost.DateCreated = DateTime.ParseExact(effectiveDate, "d. MMMM yyyy", swissGerman.DateTimeFormat);
My "effectiveDate" string is something like "27. September 2007", which is the default Swiss-German format - day (one or two digits), full month name, year (4 digits).
My problem is: the "DateCreated" always complains :
"Object reference not set to an instance of an object."
I don't understand why that's so. I checked - both methods DateTime.Parse and DateTime.ParseExact do return a valid DateTime instance. I checked the BE Core code to see what's happening with the "DateCreated" property but I'm not seeing anything
special or odd being done with it.
I even checked the admin/Pages/Add_Entry.aspx.cs file to see how BE handles its posts - I don't see any "voodoo" tricks being pulled off to get a new post into the system.
Why is my Post creation code failing all the time?? I'm running this in a console app which I'm writing, and I've added a reference to the BlogEngine.Core assembly.
What am I missing??