none
Deploying Com Interop Dlls In Windows Applications

    Question

  • Hello,

    I have a VB.NET application that is utilizing a COM component of an Open Source PDF creator called PDFCreator.  Myself and my end users have this PDFCreator tool already installed.  In my app, I add as a reference the COM executible for PDFCreator, and it attaches a dll called Interop.PDFCreator.dll.  When I run this tool on my own machine it works just fine,  but when I deploy the application to others using ClickOnce, the processes that calls the PDFCreator functions fails.  I did some reading and it seems for normal setup deployment, you can set the register flag to "vsdraDoNotRegister", however I cannot see how to do that with my app.  Secondly, I read that changing the .dll Isolated property to True might do the same thing, however this causes the code to fail in the build process.  Any thoughts on how I set this up?  Perhaps i can't do this with ClickOnce?

    Thanks!

    Tuesday, March 23, 2010 4:01 PM

Answers

  • Hi,

    My point is to NOT add the reference that way. If you add the reference that way, then you need to install that in the Global Assembly Cache on the user's machine. If you want the file to be included in the deployment as a local assembly instead of having to deploy it as a prerequisite, you have to add it to your project.

    So find the assembly you want to use. Right-click on your project and choose "add existing item", and browse to it and select the assembly. Set the properties on the file as noted above (build action and copy-to-output-directory).

    Then DELETE THE REFERENCE you have under References to the assembly, choose Add Reference, and BROWSE to the assembly you just added to your project and select it.

    This means your application will now run against the local version of it instead of the one installed onthe machine in the Global Assembly Cache (GAC).

    It will also deploy it locally with the rest of the files. Try it and see if it works. You have a 50/50 chance, and if it does, it's much easier both for you and for your customer.

    RobinDotNet


    Click here to visit my ClickOnce blog!
    Microsoft MVP, Client App Dev
    • Marked as answer by eengel821 Wednesday, March 24, 2010 6:22 PM
    Wednesday, March 24, 2010 1:54 AM
    Moderator

All replies

  • Hi,

    You need to find out if you can deploy that DLL locally rather than having it installed in the GAC.

    Add the dll to your project. Mark it "build action=none" and set "copy to output directory" to "do not copy".

    Delete your reference to the application that probably points to yours in the GAC. Re-add the reference, and select the dll deployed locally in your project. Set "copy local" to "true".

    Now it will deploy the dll, and try to use it locally. Give it a try and see if it works.

    If it doesn't work, you're going to need to wrap it in a setup & deployment package and deploy it as a prerequisite. If you end up having to go that way, post back and I'll give you the info about it. The only way to tell if this is going to work is to try it. For example, it works with DirectX (which surprised me), but not with Infragistics controls.

    RobinDotNet


    Click here to visit my ClickOnce blog!
    Microsoft MVP, Client App Dev
    Tuesday, March 23, 2010 7:51 PM
    Moderator
  • Thanks RobinDotNet.  I'm a bit of a newbie for this, so I'm having trouble seeing how I can set the "build action" and some of the other items you mentioned.  When I add the reference, I'm just right clicking the Reference node in the solution explorer within VS2005 and adding the PDFCreator.exe from the COM tab.  After I've referenced it, the properties window doesn't have those options.  I think I'm either importing the .dll in the wrong manner or I'm not looking in the right place to do this.  Could you point me in the right direction?  Thanks for your help in answering so far!

    Thanks!

    Tuesday, March 23, 2010 9:08 PM
  • Hi,

    My point is to NOT add the reference that way. If you add the reference that way, then you need to install that in the Global Assembly Cache on the user's machine. If you want the file to be included in the deployment as a local assembly instead of having to deploy it as a prerequisite, you have to add it to your project.

    So find the assembly you want to use. Right-click on your project and choose "add existing item", and browse to it and select the assembly. Set the properties on the file as noted above (build action and copy-to-output-directory).

    Then DELETE THE REFERENCE you have under References to the assembly, choose Add Reference, and BROWSE to the assembly you just added to your project and select it.

    This means your application will now run against the local version of it instead of the one installed onthe machine in the Global Assembly Cache (GAC).

    It will also deploy it locally with the rest of the files. Try it and see if it works. You have a 50/50 chance, and if it does, it's much easier both for you and for your customer.

    RobinDotNet


    Click here to visit my ClickOnce blog!
    Microsoft MVP, Client App Dev
    • Marked as answer by eengel821 Wednesday, March 24, 2010 6:22 PM
    Wednesday, March 24, 2010 1:54 AM
    Moderator
  • OK I tried that.  Looks like it's not going to work for my application so I'll probably need to transfer my application into a setup & deployment package instead.  Thank you very much for your help on this!
    Wednesday, March 24, 2010 2:33 PM
  • Your customers already have it installed, but the problem is your application references it, right?

    You can try this: open the Application Files dialog -- is the dll there? If so, mark it as "exclude" or "do not include" or whatever it is so it doesn't include it with the deployment. After all, if your customers already have it installed, you don't need to deploy it.

    Give it a try and see if it works.

    RobinDotNet


    Click here to visit my ClickOnce blog!
    Microsoft MVP, Client App Dev
    Monday, March 29, 2010 6:19 AM
    Moderator
  • Your customers already have it installed, but the problem is your application references it, right?

    You can try this: open the Application Files dialog -- is the dll there? If so, mark it as "exclude" or "do not include" or whatever it is so it doesn't include it with the deployment. After all, if your customers already have it installed, you don't need to deploy it.

    Give it a try and see if it works.

    RobinDotNet


    Click here to visit my ClickOnce blog!
    Microsoft MVP, Client App Dev
    Monday, March 29, 2010 6:19 AM
    Moderator
  • Same exact scenario for me - would eengel821 be so kind as to post specifics on what they did?

    I actually had this working in the past using some type of reference to PDFCreator (unfortunately, did not document my work). Now my company seems to have updated PDF Creator across most of the client installations. I cannot for the life of me remember how to get this to work right.

    When I reference the PDF Creator from the COM tab, I end up with two items imported to my list of references:

    • Interop.PDFCreator.dll
    • Interop.VBA.dll

    When I write code in Visual Studio against PDF Creator, it clearly needs a reference to Interop.PDFCreator.dll, but, if I undestand RobinDotNet, once I deploy my code to client machines which already have PDFCreator installed, I should be able to omit this Interop.PDFCreator.dll assembly?

    Friday, July 09, 2010 8:02 PM
  • I didn't document my process real well either, but I can tell you where I added things and what properties were set.

    1.) Added the PDFCreatore.exe to my references and set properties to:

    isolated = false

    CopyLocal = True

     

    - doing this seemed to create an Interop.PDFCreator.dll file

     

    2.) Added the Interop.PDFCreator.dll to my Installer with properties:

    Exclude = False

    Folder = Application Folder

    Hidden = False

    PackageAs = vsdpaDefault

    Permanent = False

    ReadOnly = False

    Register = vsdraDoNotRegister

    SharedLegacyFile = False

    System = False

    Transitive = False

    Vital = True

     

    3.) Doing this seemed to add the .exe and .dll to my DetectedDependancies folder in my installer.

     

    4.) When you right click the installer in the solution tree, and view the File System, the interop.PDFCreator.dll file shows up here. 

     

    Hope that helps.  Wish I could tell you what order I did things to make it work, but I tried like a 100 different combinations until it worked.

     

     

    Monday, July 12, 2010 5:13 PM
  • Thanks for the feedback. My app gets used on a CITRIX server, where we use an MSI to install it. So, your comments above will be very applicable.

    However, I currently roll it out to our office users via ClickOnce.. so, I'll reply back with my findings it I ever figure this back out again.

    Thanks -


    B

    Thursday, July 15, 2010 4:44 PM