Adventures with .NET and COM

I was working with PDFCreator and downloaded the 0.9.7 release. It refused to install the pdfforge .NET dll because it said I hadn’t got .NET 1.1. Well, as most .NET 1.1 assemblies will run happily in .NET 2.0, I thought I’d have a go with it.

I got the pdfforge dll and test scripts from SourceForge and tried the scripts. No dice. So next I looked at the assembly in Reflector and found an unresolved reference to iTextSharp, which also thinks its a .NET 1.1 assembly. The plot thickens though, as when I got the iTextSharp DLL, it still wouldn’t load it. It turns out that in the comments in SVN, the pdfCreator guys did say they built iTextSharp from source, and they’re reference is to v without a strong name, whereas the latest release binary of iTextSharp is with a strong name. In order to get them to “talk” I needed to either change the reference baked in to pdfforge.dll or change the assembly version baked in to iTextSharp (and remove it’s strong name), or build iTextSharp from source…

Well, enter the Reflexil add-in for Reflector. Wow! With this I had a choice – it’ll let me fiddle with assembly versions, strip strong names, fiddle with assembly references, even hack the code & save it back. Get it from SourceForge.



So, with my demo code running nicely in c#:

using System;
using pdfforge.PDF;

namespace AcsComms
    class Program
        static void Main( string[] args )
            PDF pdf = new PDF();
            pdf.CreatePDFTestDocument( @"C:\Temp\PDF\Testy.PDF", 1, "Have at it, matey!" );

I tried to RegAsm the pdfforge.dll. Two gotchas here.

  1. The first time I did it, I forgot to use the /codebase option, so COM & mscoree couldn’t find the DLL.
  2. On my x64 Vista, I used the RegAsm in C:\Windows\Microsoft.NET\Framework\v2.0.50727, which is 32-bit. Consequently the registry entries got written to HKEY_CLASSES_ROOT\Wow6432Node\CLSID, and I could only use the DLL in 32-bit land, e.g.

    C:\Windows\SysWOW64\wscript.exe "C:\Program Files (x86)\PDFCreator\PlugIns\pdfforge\nUp.vbs"

    This was fixed by re-running RegAsm in the 64-bit framework directory:

    C:\Windows\Microsoft.NET\Framework64\v2.0.50727\regasm "c:\Program Files (x86)\DFCreator\PlugIns\pdfforge\pdfforge.dll" /codebase


So now I can just double-click on the demo .vbs scripts and they work just fine!

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s