hexagon logo

Add Reference to PCDLRN.tlb not working

Apologies for the duplicate post there was a timeout first time around and I didn't think it was posted! (Can't figure out how to delete it either!)

I'm need to do some VB.Net development on a pc that doesn't have PC-DMIS installed. My understanding is that I need to add a reference to PCDLRN.tlb but when I try that I get the following error:

---------------------------
Microsoft Visual Studio Express 2012 for Windows Desktop
---------------------------
A reference to 'C:\pcdlrn.tlb' could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.

I'm running VSE2012 on Windows 7 64bit. Any ideas what is going on here?

I can add reference to the same file in excel VBA on the pc with PC-DMIS installed without any issues.

Also, where can I get the Object Library reference material? I've seen other post refer to this link but it doesn't work anymore... http://www.wilcoxassoc.com/downloads/dl_documentation.php

Thanks!
  • Update

    I just tried adding the reference to a VB6 project and it worked ok???
  • You need to register the type library so that Visual Studio recognizes it as a COM reference. When PC-DMIS is installed it will do this for you, otherwise you have to do it yourself.

    Copy the type library file (pcdlrn.tlb) from the PC-DMIS application directory of the PC it's installed on to an easy to find location (like on root of C) on your PC. On your PC, open a command prompt window, and execute the following:

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\regtlibv12.exe C:\pcdlrn.tlb


    Documentation is available on the Wilcox FTP site: ftp://ftp.wilcoxassoc.com/docs/
  • Thanks for the info but while the reference is added the VS object browser isn't showing any of the class methods! Again I can see the methods fine in VB6
  • Update:

    I changed the object browser settings to show hidden members and it now shows a hidden duplicate of every class with class appended to the name.

    For example:
    ActiveTip shows no methods but the hidden ActiveTipClass shows all the methods etc. that ActiveTip should have.

    How can I fix this?
  • Update:

    I changed the object browser settings to show hidden members and it now shows a hidden duplicate of every class with class appended to the name.

    For example:
    ActiveTip shows no methods but the hidden ActiveTipClass shows all the methods etc. that ActiveTip should have.

    How can I fix this?


    I believe that it is working correctly. Does the Does the ActiveTip that is not hidden have an "I" in front of it?
  • No it doesn't. I should say that it does work in the code but it has the very annoying effect of not prompting to auto-complete class members which means typing everything out in full. I've attached 2 screen shots to show comparison:

  • I don't know what your level of experience is with VB, so please don't be offended if this is below you. It sounds like it might be your issue here...

    Are you declaring your application documents as the underlying types (early-bound) and not as generic objects (late-bound)?

    If you do late-binding like what you see in a lot of the BASIC scripting posted on this forum, VS does not resolve the object types until run-time. Since the types are not known at design time, Intellisense (auto-complete) won't work:

    Dim pcdApp as Object = CreateObject("PCDLRN.Application")
    Dim pcdParts as Object = pcdApp.PartPrograms
    Dim pcdPart as Object = pcdApp.ActivePartProgram


    If you try to address the properties of any of these objects, all Intellisense will give you is the generic properties of System.Object.

    In order for Intellisense to do it's job, it needs early-bound objects like this:

    Dim pcdApp as PCDLRN.Application = CreateObject("PCDLRN.Application")
    Dim pcdParts as PCDLRN.PartPrograms = pcdApp.PartPrograms
    Dim pcdPart as PCDLRN.PartProgram = pcdApp.ActivePartProgram


    You can also add a qualifier to avoid typing out "PCDLRN" so much:

    Imports PCDLRN
    Public Class Foo
    
    Dim pcdApp as Application = CreateObject("PCDLRN.Application")
    Dim pcdParts as PartPrograms = pcdApp.PartPrograms
    Dim pcdPart as PartProgram = pcdApp.ActivePartProgram
    
    End Class


    Now, whenever you address pcdApp, pcdParts, or pcdPart, Intellisense will provide you with all the members.
  • Thank you for your reply.

    Yes that was exactly my problem but I had tried that originally and I was getting an error of some sort but when I tried it again to see what the error was it worked fine...?? Weird! It should have been obvious that that was the reason for Intellisense not working but it never occurred to me so thanks for pointing that out!

    It has led to one strange problem in my code though, after changing to early binding, I can't loop through the commands with a for each loop ie:

    Dim PCDApp As PCDLRN.Application = GetObject("", "PCDLRN.Application")
    Dim pcdPartProg As PCDLRN.PartProgram = PCDApp.ActivePartProgram
    Dim pcdCommands As PCDLRN.Commands = pcdPartProg.Commands
    
    For Each cmd In pcdCommands
    Next


    I get the error:

    Expression is of type 'PCDLRN.commands', which is not a collection type.

    for pcdCommands.

    This same code works fine when I declare each variable as Object... What am I missing here?

    I know I can do:

    For i = 0 To pcdCommands.Count - 1
    Next


    but I'm curious to know why the former doesn't work with early binding.
  • I've experienced that issue as well. I believe PCDLRN.Commands (like PCDLRN.PartPrograms and other PC-DMIS "collection" types) does not actually inherit System.Collections. As a result, the Common Language Runtime (the go-between level between VS and the CPU) is unable to compile it in a For...Each...Next (collection-based) loop.

    The PCDLRN.Commands object, while not inheriting System.Collections, does still contain an index property and can be interpreted/compiled by the CLR in a For...Next (index or count-based) loop.

    TL;DR: I think your only choice is to use count-based loops. My theory, FWIW.
  • Seems strange that it wasn't set up to inherit System.Collections... But what you say makes sense to me so my curiosity is satisfied Slight smile Thanks again for your help!