CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2011
    Posts
    1

    DLL Registration Issue

    I have designed a C# program in VS2008 (.NET 3.5). the purpose of the program is to use my brokerage's COM dll components to connect to them and pull quote history automatically every so often for analysis in my other program which emails me updates and possible trade decisions.

    my program works just fine but the issue is knowing when to register the DLL's or not. What I mean is that if the user has the brokerage's software already installed on the machine then there is no need to register them. in fact, doing so will work temporarily but if my program is uninstalled them the brokerage software doesn't work. i had to uninstall, reinstall, and reboot before the brokerage software would work after registering "my" DLL's.

    i am using a batch file script to execute regsvr32 commands on the DLL's in my program's installation directory and what i believe what is happening is that there is only one entry in the registry for a given CLSID and therefor, when my program is installed and runs for the first time it registers the ones in my directory. then if i uninstall mine, the entries are gone or invalid and the brokerage software cannot load the objects because the CLSID entry in the registry is either missing or points to a file that no longer exists.

    how would i go about ensuring that my program does not screw up the brokerage software while still working on machines that don't have it installed? is there a way to use the COM DLL's in my directory WITHOUT having them registered with the system? that would solve the problem. if not, how would i go about this? would i have to write code to check the registry for valid entries for each CLSID and if it does not exist, then register that DLL?


    Thanks in advance,

    -Ryan

  2. #2
    Join Date
    Dec 2007
    Posts
    234

    Re: DLL Registration Issue

    You do it by using a proper install program that will correctly register the DLLs.

    When multiple apps try to register the same DLL, the registry is updated to reflect that the DLL is now "shared" ... so if one app then tries to uninstall, shared DLLs should get left alone until the "used by" count returns back to 0. Because of the method you are using, this "app count" isn't being updated.

    -tg
    * I don't respond to private requests for help. It's not conducive to the general learning of others.-I also subscribe to all threads I participate, so there's no need to pm when there's an update.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help - how to remove eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to???
    * On Error Resume Next is error ignoring, not error handling(tm). * Use Offensive Programming, not Defensive Programming.
    "There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN
    MVP '06-'10

  3. #3
    Join Date
    Feb 2011
    Posts
    1

    Re: DLL Registration Issue

    thanks for the advice. that's a good way to do it. the problem is that when i try to use the self registration feature of the windows installer setup projects in Visual Studio, VS2008 crashes every time when i try to build the solution.

    i can't seem to figure out how to fix it so i had to come up with a workaround. but that was the first thing i had tried. i wrote some code last night and tested it today on 3 machines, and it appears to work.

    when the program starts up, it checks to see if the needed COM dll's are registered with the system by reading the registry entries in classes root \ CLSID. if the entry is there and the file it references actually exists (i.e. not a leftover registry value that points to a missing file), then do nothing - otherwise, register my copies included with the installer.

    tried it on one machine that had the brokerage software, and 2 that did not. all 3 seem to function fine.

    from what i read elsewhere you apparently can do a "registration free COM" usage by using a manifests file. but i am not familiar with that and judging by the page i was reading, that technique is a little bit above my skill level at this time.

    i also noticed that with the more recent versions of my brokerage software they are using the manifest method AND registering the COM DLL's for people like me who want to use the SDK package.

    when i "broke" the software the other day it was using a slightly older version which did not use the manifest method. my father was using the latest version and he told me the program i sent him did not break his. i couldn't figure out why...but now i know.



    thanks again,

    -Ryan

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: DLL Registration Issue

    VS has a setup tool, that can deploy to x86 or x64 bit OS's

    Once you get the basics down, with a simple project, and figure out HOW to do it, it will work in 99% of the cases.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured