Help creating VB6 com objects from atl service
-
Hi, I created a new ATL service using vs.net 2003. In the PreMessageLoop function I create a new thread which does some work (after calling the parent PreMessageLoop method), the rest of the standard service code is unchanged. In this thread I create an instance of a CComObject which is in the same atl project using CComObject::CreateInstance(&a);. This CComObject is free threaded and I've defined free threading in stdafx.h. CoInitializeEx is properly called with multithreading. After the instance is created, a method is called on the object (A->Load()). In this method (Load) I create an CComPtr vb; object using CoCreateInstance (CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER) which is an instance of a com object from a VB6 dll. When I call a method on this newest object (vb), I get a whole bunch of exception errors (First-chance exception at 0x7c57e592 in MyService.exe: Microsoft C++ exception: long @ 0x0151c7e0.) in the output window (thousands of these errors) and my code appears to be hung (it should complete the method call in about 30 seconds, but goes on for minutes before I kill it). I am checking all the hresults before this and they all succeed. However, if I put my VB6 project in debug mode, my c++ code proceeded just fine, i.e. no errors. It's the same project that created the dll used by ATL and everything is registered properly. Some other methods on this dll work properly (such as fetching the threadid) either way (debug and non-debug). Any ideas? Thanks On a related note, is it not possible to debug services in "service" mode? When I register it as a service it won't run since I think StartServiceCtrlDispatcher fails.
-
Hi, I created a new ATL service using vs.net 2003. In the PreMessageLoop function I create a new thread which does some work (after calling the parent PreMessageLoop method), the rest of the standard service code is unchanged. In this thread I create an instance of a CComObject which is in the same atl project using CComObject::CreateInstance(&a);. This CComObject is free threaded and I've defined free threading in stdafx.h. CoInitializeEx is properly called with multithreading. After the instance is created, a method is called on the object (A->Load()). In this method (Load) I create an CComPtr vb; object using CoCreateInstance (CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER) which is an instance of a com object from a VB6 dll. When I call a method on this newest object (vb), I get a whole bunch of exception errors (First-chance exception at 0x7c57e592 in MyService.exe: Microsoft C++ exception: long @ 0x0151c7e0.) in the output window (thousands of these errors) and my code appears to be hung (it should complete the method call in about 30 seconds, but goes on for minutes before I kill it). I am checking all the hresults before this and they all succeed. However, if I put my VB6 project in debug mode, my c++ code proceeded just fine, i.e. no errors. It's the same project that created the dll used by ATL and everything is registered properly. Some other methods on this dll work properly (such as fetching the threadid) either way (debug and non-debug). Any ideas? Thanks On a related note, is it not possible to debug services in "service" mode? When I register it as a service it won't run since I think StartServiceCtrlDispatcher fails.
Well, upon further testing my code works just fine when the service is register and started, so I'm guessing the problem comes in when trying to run the service in debug mode in vs.net. Anyone have link on how to debug a service? It seems that just unregistering the service, compiling in debug mode and then running it doesn't work correctly. I haven't fully traced into the ATL code yet though.