Getting your COM component Registered for use with PowerBuilder

Posted on Monday, November 5th, 2012 at 7:29 pm in

I built a COM component to allow for the taking of pictures from a webcam in PowerBuilder. The component itself was done in Visual Studio 2010 in C# and makes use of a web camera control created to use the Directshow API library available as part of the Windows SDK. You can find more information on this here.

Using the techniques I’ve described in earlier posts, I created an interop project, dropped the webcam object on it, and exposed various methods and properties I needed to make the thing work. Testing on my PC worked fine; issues arose when I tried to register the thing on another PC.

The deployment of this component involves two dll files, one for the web camera control and the other for the interop wrapper control that the webcam sits on. I’m sure there are ways to incorporate the one into the other without the need for two dlls but that’s something to tackle later.

The web camera control project was set up as a standard class library. Since the second project I started with utilized the “VB6 Interop UserControl” template, it was already marked as COM visible when it was created. Once the web camera project was built I put a reference to it into my second project and made sure the setting to ‘copy local’ was set.

Once the project was complete and built, I could place the control onto a window in PowerBuilder and use it without problems. When I go to register the dlls on a separate PC (Windows 7 64 bit) I’m going to use the regasm utility. I copy all the files from the second project \bin folder to the PC then, from a command prompt, execute “Regasm webcamera.dll”.

This gives me the reply: RegAsm : warning RA0000 : No types were registered.

I do some searching on the internet and MSDN I find and set up the following in my projects.

Flag the Web Camera Control project to be COM visible. See the following:

Sign the assembly. You can create the strong name key file from the dropdown.

Do this for both projects (each has its own key file).

Copy all the files from your project’s output folder to the PC you wish to register the control on and execute the following for each project:

regasm PBWebcam.dll /codebase /tlb: PBWebcam.tlb
regasm WebCameraController.dll /codebase /tlb: WebCameraController.tlb

Leaving out the “/tlb” section will register the control, and you can see it in PowerBuilder, but you won’t have access to any methods/properties on the control. For further information on regasm go here.  You can avoid some of this mess by putting the dll into the Global Assembly Cache (GAC) but that’s a whole different can of….

You might also be interested in