The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,262 other subscribers

Archive for July, 2012

List of the bugs that are fixed in SQL Server 2008 R2 Service Pack 2

Posted by jpluimers on 2012/07/31

Close to 5 months after SQL Server 2012 got released to manufacturing, SQL Server 2008 R2 Service Pack 2 became available last week (July 26th, 2012).

A few links:

–jeroen

Posted in Database Development, Development, SQL Server, SQL Server 2008 R2, SQL Server 2012 | Leave a Comment »

.NET/C#: Generating a WordPress posting categories page – part 1

Posted by jpluimers on 2012/07/31

From the category cloud it is hard to see that the categories are organized as a hierarchy. The combobox on the right shows that, but does not have room to properly show the hierarchy. Since WordPress.com does not allow you to deploy your own code, I worked around it in this way using a small .NET C# console program:

  1. Extract the HTML for the All Categories combobox on the right of the page.
  2. Convert that HTML to XHTML (and therefore XML)
  3. Generate XSD from that XML
  4. Generate C# class wrappers from the XSD

Future posts will show more logic on how to handle the imported information, and generate nice category overviews. Preliminary source code is at the BeSharp.net source repository.

Extract the HTML

The HTML is not fully accurate (see my post on HTML and XML escapes from last week), but it is fairly easy to extract. Most web browsers allow you to view the source of your web page. Do that, then search for “All Categories”. Now you see HTML like this:

</pre>
<h2 class="widgettitle">All categories</h2>
<pre><select class="postform" name="cat"><option value="-1">Select Category</option></select><select class="postform" name="cat"><option class="level-0" value="256">About  (66)</option></select><select class="postform" name="cat"><option class="level-1" value="64">   Personal  (60)</option></select><select class="postform" name="cat"><option class="level-2" value="20254983">      Adest Musica  (7)</option></select><select class="postform" name="cat"><option class="level-2" value="32122">      Certifications  (2)</option></select><select class="postform" name="cat">...</select><select class="postform" name="cat"><option class="level-0" value="756">Comics  (3)</option></select><select class="postform" name="cat"><option class="level-0" value="780">Development  (473)</option></select><select class="postform" name="cat"><option class="level-1" value="872460">   Database Development  (55)</option></select><select class="postform" name="cat">...</select><select class="postform" name="cat"><option class="level-0" value="9280">User Experience  (3)</option></select>

I don’t need the H2 heading line, but the rest I do need to generate XML from. I saved the HTML into a text file for processing by the console app.

Convert the HTML to XML

The HTML contains loads of &nbsp;, but XML does not allow for that entity. So the & ampersand needs to be escaped into &amp;This also solves other uses of & in the HTML. The rest of the HTML is XHTML compliant, so does not require change, which results into this C# conversion method:

        private static string toXml(string inputHtml)
        {
            string result = inputHtml.Replace("&", "&");
            return result;
        }

Generate an XSD for the XML, then amend the XSD

Given my comparison of tools for generating XSD from XML, so I used the XmlForAsp XML Schema generator, with the “Separate Complex Types” option. (Note: I will link to the XSD before/after, as WordPress – yet again – screws the XSD sourcecode in the post; this should do for now). That gives me XSD like this (XML is also at pastebin):

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <xsd:element name="select" type="selectType" />
 <xsd:complexType name="selectType">
  <xsd:sequence>
   <xsd:element maxOccurs="unbounded" name="option" type="optionType" />
  </xsd:sequence>
  <xsd:attribute name="name" type="xsd:string" />
  <xsd:attribute name="id" type="xsd:string" />
  <xsd:attribute name="class" type="xsd:string" />
 </xsd:complexType>
 <xsd:complexType name="optionType">
  <xsd:attribute name="value" type="xsd:int" />
 </xsd:complexType>
</xsd:schema>

Which is not complete, but gives a good start. The actual XSD it needs to be like this with a more elaborate optionType complex type that also defines it’s own content as deriving from xsd:string, and adds the class attribute (XML is also at pastebin):

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <xsd:element name="select" type="selectType" />
 <xsd:complexType name="selectType">
  <xsd:sequence>
   <xsd:element maxOccurs="unbounded" name="option" type="optionType" />
  </xsd:sequence>
  <xsd:attribute name="name" type="xsd:string" />
  <xsd:attribute name="id" type="xsd:string" />
  <xsd:attribute name="class" type="xsd:string" />
 </xsd:complexType>
 <xsd:complexType name="optionType">
  <xsd:simpleContent>
  <xsd:extension base="xsd:string">
   <xsd:attribute name="class" type="xsd:string" />
   <xsd:attribute name="value" type="xsd:int" />
  </xsd:extension>
 </xsd:simpleContent>
 </xsd:complexType>
</xsd:schema>

Generate C# classes from the XSD

You can generate C# wrapper classes using the XSD.exe tool that ships with Visual Studio, but XSD.exe is hard to use, is hard to integrate into Visual Studio (despite Microsoft Connect request for it), the XSD.exe generated code still needs work for deserializing, and XSD.exe has very limited generation options (heck, after it changed from .NET 1.x to 2.0, it hasn’t been updated for about a decade). XSD2Code has some great reviews, to I used that in stead. And indeed, very well integrates into Visual Studio 2010, and generates very nice C#, especially when you use the options (see also the screenshot on the right):

  • Under Serialization, set Enabled to True
  • Under Serialization, set GenerateXmlAttributes to True

That way, loading the HTML, converting it to XML, then deserializing it into object instances is as simple as this:

                string inputFileName = args[0];
                string inputHtml = getHtml(inputFileName);
                string xml = toXml(inputHtml);
                selectType select = selectType.Deserialize(xml);

More on actually working with the loaded instances in the next episode, including the great benefit of XSD2Code: it generates C# code as partial classes.

–jeroen

Posted in .NET, C#, C# 4.0, C# 5.0, Development, SocialMedia, Software Development, Usability, User Experience (ux), Web Development, WordPress, WordPress, XML, XML escapes, XML/XSD, XSD | 2 Comments »

Delphi 2007: reproduction and workaround for “[DCC Error] ….pas(26): F2084 Internal Error: AV21BCE0AC-R00000000-0”

Posted by jpluimers on 2012/07/31

Just in case you come across this error ([WayBackQC 108189):

[DCC Error] CompilerAVUnit.pas(26): F2084 Internal Error: AV21BCE0AC-R00000000-0

I had this error in a really complicated unit that I tried to backport from Delphi XE2 to Delphi 2007 (as there was some non-unicode compliant app that needed this).

I could not find it searching for F2084 Internal Error, so I sat down and trimmed it down to the CompilerAVUnit below.

The workaround is simple: remove the static; from method Outer and it compiles fine.

I will post more details on the static keyword in Delphi in a future blog post. For now I’ll keep it at this: Read the rest of this entry »

Posted in Delphi, Delphi 2007, Development, F2084, QC, Software Development | 8 Comments »

Creating vSphere 5 ESXi embedded USB Stick (failed at first in HP XW6600, but with MBR partition table it works)

Posted by jpluimers on 2012/07/30

Installing and booting ESXi 5 from USB allows you to keep your storage exclusively for VMs and separately make backup of your boot configuration and data configuration (note you cannot put the DataStore on your USB stick).

A small stick (minimum 1 gigabyte) will suffice, and works on many systems, but at first not on my HP XW6600, despite the latest BIOS version 1.36a. You get a nice “Non-System disk or disk error” message.

Both methods I tried failed at first. I thought they failed because the BIOS on the HP has limited USB boot support. It did boot from single partition USB sticks, but seemed not to boot from multi-partition ones, no matter if they are removable or HDD (with the removable bit flipped).

The ESXi5 installer is a single partition one. The final ESXi5 installed image is a multi-partition one. That’s what got me thinking into the multi-partiton direction.

Since the problem is similar to the impossibility of booting VMware workstation VMs from USB stick, (this fails even from the BIOS), I tried Plop since Plop works for VMware Workstation. The Plop USB boot manager failed too. My final thought was to install Plop on a FAT formatted USB stick(which does boot) and continue from there to the ESXi5 one: that failed too.

Boy I was wrong: the failure was not caused by the multi-partition setup, but because of my “Google blindness”: I searched in the wrong direction with the wrong keywords, therefore not getting the right links as search results.

A VMware Communities forum threads on “No bootable device” after successful ESXI5 installation on Intel DG35EC desktop motherboard” and No boot after clean install  finally got me in the right direction:

As of ESXi5, the default partition table type is GPT (GUID Partition Table), not MBR (Master Boot Record) any more (thats why an ESXi4 install will work fine).

Booting from GPT is in the EFI standards (now in its second generation UEFI or United Extensible Firmware), allowing – among others – to boot from disks bigger than 2 terrabyte. You need a BIOS that is compatible with GPT to do so, and the HP XW6600 BIOS clearly isn’t compatible with GPT.

Not all is lost, as while installing ESXi5, you have an option – though well hidden – to force it to use MBR boot. That worked, and I will blog on the steps later.

The good news: it now works on my HP XW6600 workstations (that support both VT-x and VT-d, which means I can do PCI pass through).

How to create an ESXi5 install on a USB stick

First things first though: creating the USB stick in the first place. Read the rest of this entry »

Posted in BIOS, Boot, ESXi4, ESXi5, Hardware, HP XW6600, Power User, UEFI, Virtualization, VMware, VMware ESXi | 4 Comments »

Tonido as alternative to DropBox (via: Bei sensiblen Daten lieber eigene Cloud-Lösung – c’t – PresseBox)

Posted by jpluimers on 2012/07/30

On the research list (wow, Google Translate is very accurate this time!): Tonido

More and more programs allow users to cut the cord of cloud providers like Google and Dropbox. The Tonido software is suitable for example for users who want to make sensitive customer or patient data accessible on multiple devices without outsourcing it to an external server. “Once you have installed Tonido on your PC and create an account, you can in the local network, but also on the move access to a PC or mobile devices on the complete data set”

Original German text from the mid December 2011 issue of c’t Magazin:

Immer mehr Programme ermöglichen es Anwendern, sich von Cloud-Anbietern wie Google oder Dropbox abzunabeln. Die Software Tonido eignet sich beispielsweise für Nutzer, die sensible Kunden- oder Patientendaten auf mehreren Geräten zugänglich machen wollen – ohne sie auf einen externen Server auszulagern. “Sobald man Tonido auf dem eigenen PC installiert und ein Konto angelegt hat, kann man im lokalen Netz, aber auch von unterwegs mit PC oder Mobilgeräten auf den kompletten Datenbestand zugreifen”

Thanks Noud van Kruysbergen for translating the German c’t article into Dutch.

–jeroen

via: Bei sensiblen Daten lieber eigene Cloud-Lösung – c’t – PresseBox.

Posted in *nix, Linux, Mac, Mac OS X / OS X / MacOS, Mac OS X 10.5 Leopard, Mac OS X 10.6 Snow Leopard, Mac OS X 10.7 Lion, Power User, Windows, Windows 7, Windows 8, Windows Server 2003, Windows Server 2008, Windows Vista, Windows XP | Leave a Comment »