Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling a (VB) COM+ object from an (C++) NT Service

Status
Not open for further replies.

szfq93

Programmer
Jul 12, 2002
11
US
I have written a VB6 ActiveX DLL and successfully installed/accessed it on a remote server (via COM+). I've also written a C++ NT service that must access this remote COM+ app.

If I run the C++ application as a console app (vs as a true NT service), it works. But, once installed as an NT service, the service fails upon my very first call to a function located inside the COM+ object.

Here's how my C++ service is set up:
========================================================
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
...
//create COM+ object
mTisc.CreateInstance(__uuidof (clsTISC));
//Call function within newly created instance
mTisc->SetPropertiesFromINI("C:\\TISC.INI");//Pgm fails here!

========================================================
Could this be a roles/security issue? Or, has it to do with my use of COINIT_APARTMENTTHREADED? Remember, this same code works if I run the program as a console app.

Any help would be greatly appreciated!!
 
Most likely its a security problem. Services most often run as the local system admin account or NULL which another machine will reject for security reasons. Set your service to run with a domain account that has local admin privilages and you should do better. When you run it in console it is using your access writes and either you are using a domain account or you are using a local account that the other machine happens to have with the same password. This is comon in situations where you may be logged in locally to a machine as administrator and all machines on your network have the local administrator set with the same password.

 
I found out that security setup was PART of the problem. Once I fixed up the security issue, there was still the issue with calling CoInitializeEx to setup COM. Since this is an NT service, calling CoInitializeEx at app startup (actually, at class instance start-up - C++ you know!) would not suffice - I have to call it WITHIN the thread that actually makes calls to the COM+ object.

So, to make a long story short, I fixed my security; made a call to CoInitializeEx before my main service loop (within the "run" section of the service) and it works!

Thanks for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top