{"id":1508,"date":"2012-11-05T19:29:08","date_gmt":"2012-11-06T00:29:08","guid":{"rendered":"http:\/\/anvil-of-time.com\/wordpress\/?p=1508"},"modified":"2021-03-11T12:51:02","modified_gmt":"2021-03-11T17:51:02","slug":"getting-your-com-component-registered-for-use-with-powerbuilder","status":"publish","type":"post","link":"https:\/\/anvil-of-time.com\/powerbuilder\/getting-your-com-component-registered-for-use-with-powerbuilder\/","title":{"rendered":"Getting your COM component Registered for use with PowerBuilder"},"content":{"rendered":"<p>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 <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/dd375454(v=vs.85).aspx\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n<p>Using the techniques I&#8217;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.<\/p>\n<p>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&#8217;m sure there are ways to incorporate the one into the other without the need for two dlls but that&#8217;s something to tackle later.<\/p>\n<p>The web camera control project was set up as a standard class library. Since the second project I started with utilized the &#8220;VB6 Interop UserControl&#8221; 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 &#8216;copy local&#8217; was set.<\/p>\n<p><a href=\"http:\/\/anvil-of-time.com\/wordpress\/wp-content\/uploads\/2012\/11\/PBregasm000.png\"><img loading=\"lazy\" class=\"aligncenter wp-image-1511 size-full\" title=\"PBregasm000\" src=\"https:\/\/anvil-of-time.com\/wp-content\/uploads\/2012\/11\/PBregasm000.png\" alt=\"\" width=\"378\" height=\"158\" srcset=\"https:\/\/anvil-of-time.com\/wp-content\/uploads\/2012\/11\/PBregasm000.png 378w, https:\/\/anvil-of-time.com\/wp-content\/uploads\/2012\/11\/PBregasm000-300x125.png 300w, https:\/\/anvil-of-time.com\/wp-content\/uploads\/2012\/11\/PBregasm000-150x62.png 150w\" sizes=\"(max-width: 378px) 100vw, 378px\" \/><\/a><\/p>\n<p>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&#8217;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 &#8220;Regasm webcamera.dll&#8221;.<\/p>\n<p>This gives me the reply: RegAsm : warning RA0000 : No types were registered.<\/p>\n<p>I do some searching on the internet and MSDN I find and set up the following in my projects.<\/p>\n<p>Flag the Web Camera Control project to be COM visible. See the following:<\/p>\n<p><a href=\"http:\/\/anvil-of-time.com\/wordpress\/wp-content\/uploads\/2012\/11\/PBregasm001.png\"><img loading=\"lazy\" class=\"aligncenter wp-image-1512 size-large\" title=\"PBregasm001\" src=\"https:\/\/anvil-of-time.com\/wp-content\/uploads\/2012\/11\/PBregasm001-1024x358.png\" alt=\"\" width=\"800\" height=\"280\" srcset=\"https:\/\/anvil-of-time.com\/wp-content\/uploads\/2012\/11\/PBregasm001-1024x358.png 1024w, https:\/\/anvil-of-time.com\/wp-content\/uploads\/2012\/11\/PBregasm001-300x104.png 300w, https:\/\/anvil-of-time.com\/wp-content\/uploads\/2012\/11\/PBregasm001-150x52.png 150w, https:\/\/anvil-of-time.com\/wp-content\/uploads\/2012\/11\/PBregasm001.png 1029w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n<p>Sign the assembly. You can create the strong name key file from the dropdown.<\/p>\n<p><a href=\"http:\/\/anvil-of-time.com\/wordpress\/wp-content\/uploads\/2012\/11\/PBregasm002.png\"><img loading=\"lazy\" class=\"aligncenter wp-image-1510 size-full\" title=\"PBregasm002\" src=\"https:\/\/anvil-of-time.com\/wp-content\/uploads\/2012\/11\/PBregasm002.png\" alt=\"\" width=\"682\" height=\"403\" srcset=\"https:\/\/anvil-of-time.com\/wp-content\/uploads\/2012\/11\/PBregasm002.png 682w, https:\/\/anvil-of-time.com\/wp-content\/uploads\/2012\/11\/PBregasm002-300x177.png 300w, https:\/\/anvil-of-time.com\/wp-content\/uploads\/2012\/11\/PBregasm002-150x88.png 150w\" sizes=\"(max-width: 682px) 100vw, 682px\" \/><\/a><\/p>\n<p>Do this for both projects (each has its own key file).<\/p>\n<p>Copy all the files from your project&#8217;s output folder to the PC you wish to register the control on and execute the following for each project:<\/p>\n<pre>regasm PBWebcam.dll \/codebase \/tlb: PBWebcam.tlb\nregasm WebCameraController.dll \/codebase \/tlb: WebCameraController.tlb<\/pre>\n<p>Leaving out the &#8220;\/tlb&#8221; section will register the control, and you can see it in PowerBuilder, but you won&#8217;t have access to any methods\/properties on the control. For further information on regasm go <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/tzat5yw6(v=vs.80).aspx\" target=\"_blank\" rel=\"noopener\">here<\/a>. \u00a0You can avoid some of this mess by putting the dll into the Global Assembly Cache (GAC) but that&#8217;s a whole different can of&#8230;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,10],"tags":[49,50,12,67],"_links":{"self":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/1508"}],"collection":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/comments?post=1508"}],"version-history":[{"count":5,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/1508\/revisions"}],"predecessor-version":[{"id":2059,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/1508\/revisions\/2059"}],"wp:attachment":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/media?parent=1508"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/categories?post=1508"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/tags?post=1508"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}