I'm not 100% sure this should be under COM interop but it seems appropriate enough.
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
Loading
Sam HobbsPosted Feb 3, 2011, 4:36 PM
Ryan TurcottePosted Feb 3, 2011, 4:22 PM
if this registration free COM activation thing doesn't work out or is not a suitable option, i will just write code to check to see whether the existing DLL's are already registered with the system and if not, then register them. that way i should be safe.
Sam HobbsPosted Feb 3, 2011, 4:03 PM
That Registration-Free Activation of COM Components article looks interesting but I get the impression that you are looking for a way to avoid learning about how to register COM components and related topics. For that purpose, the article is useless. Right?
Ryan TurcottePosted Feb 3, 2011, 3:55 PM
http://msdn.microsoft.com/en-us/library/ms973913.aspx
i understand what they are saying you can do, but actually achieving it is another story. i will have to play around with this as well as this option seems the best.
thanks again.
Ryan TurcottePosted Feb 3, 2011, 3:45 PM
now i at least know i must register the 4 COM components with the system. i suppose i will have to check if the CLSID and ProgID's are in the registry and linking to a valid, existing file. if not, then i can use the regsvr32.exe, or a batch script, or the source code like you suggested to call the built in function for self registration. i like that last option the best and i think i'll explore that one.
i will also check out Suthish's link about the GAC as that might be another way to do it.
thanks,
-Ryan
Sam HobbsPosted Feb 3, 2011, 2:47 PM
Most COM objects are self-registering, which means that they have a function that updates the registry as needed to register them. The source code for the regsvr32 tool is available as a C++ sample program. Essentially all it does is to call the function in the DLL for the DLL to register itself. So you can simplify your programming by writing code to call the registration function directly.
It seems to me that setup programs should do all that for you. If it were me, I would sure try to use the existing tools.
I don't understand everything you said but I hope this helps and you can ask for clarification if needed.
Suthish NairPosted Feb 3, 2011, 2:11 PM
Ryan TurcottePosted Feb 3, 2011, 1:30 PM
maybe i'm not correctly referencing them? how do i ensure that i am?
Suthish NairPosted Feb 3, 2011, 1:11 PM
did you to tried to run your application without installing the software.
Or wait for more best replys.