May 9, 2015

Some COM for you - Chapter 3

We finished Chapter 2 having registration-free COM working, but having 3 files (.dll, .tlb and .manifest) instead of single .dll. Now, it's possible to embed both .tlb and .manifest into .dll.

Here's the recipe.

May 3, 2015

Some COM for you - Chapter 2

In which Tigger COM is unbounced

...what they should do is take Tigger on a long walk to somewhere where he won't know where he is, and then leave him there, and when they go back to find him the next morning 

he will have learnt his lesson and been unbounced.
A. A. Milne

We ended chapter 1 having working Delphi - .Net interop via COM, but with one unfortunate issue - a need to register a library on every machine with absolute path. A solution for this would be to use Registration-free COM also known as Side-by-Side COM. This chapter is how to make it work, and though it worked in the end, the whole process is a bit thorny and winding and fragile and... well, it's possible to make it work still.

Rube Goldberg coffee machine by Dina Belenko

Mar 21, 2015

Some COM for you - Chapter 1

In which Piglet Meets a Heffalump Delphi meets .Net

"I saw one once," said Piglet. "At least, I think I did," he said. "Only perhaps it wasn't."
A. A. Milne

If you ever programmed for Windows, you should have heard weird stories of evil COM that lurks there in shadows waiting to drag you into the abyss of marshalling and IUnknowns...

As for me, I remembered Joel saying that when Microsoft first presented COM, they were proud to say that "it requires at least 20 000 lines of code just to get started". (Strangely, I can't find that line on his site anymore, can somebody help me with it?) So I never had any will to learn COM through (which may be not the best part of me), but anyway.

When I found that I need to use some COM libraries in a desktop app I decided to study C# because .Net has been said to have native COM support and I should not have to worry about the details. (And this was for the better, actually! I was prejudiced against C# knowing that Gosling blamed it for having unsafe code, but it turned out that C# is actually a better Java, and I like it!).

So when I recently found that I have to make a C# library to work with Delphi app and the only way to do it is COM, I started preparing for worst. Below is a story of how to make this work, which I'd like to keep in case I'll need to do something like that again.

The problem just reminded me about this promising energy source