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

6 Comments

Add your comment

  1. DisplacedGuy - November 28, 2012 at 12:57 am

    Thanks for the info, I had never used a signed assembly before. I have created a link to you website from my PowerBuilder related website (http://www.displacedguy.com) was wondering if you would do the same and add me to your blogroll? Thanks– Rich

  2. Antonis.Sna - February 15, 2013 at 3:42 am

    Also an easy way is to execute the above steps and then build a setup project from Visual Studio. Then you can use it easily on both deployment and development computers.

    Also the above is a standard method when you build assemblies without Interop Form Toolkit for use within PB using ConnectToNewObject()

    Thanks, Sna.

  3. prashant - March 17, 2014 at 8:12 am

    hi

    I am using PB 11.5 Classical is it possible that it works on PB 11.5 ? alos one more request to community if anybody has ever compiled c# componets that will work with pb11 please share. Its very difficult for us to recreate as i am against the piracy so please share the component if you already compiled with us any any script on how to use it.

    We been talking about webcam Capture Component

Leave a Reply

Top