Atl NT service calling VB ActiveX dll had problem when clean-up 
Author Message
 Atl NT service calling VB ActiveX dll had problem when clean-up

I have a NT service written by ATL in VC6.0sp5 on Win2000advsp2. My service
first lauchs a work thread then waits for user control message. The work
thread will call a VB6.0 activeX dll, do some work in a loop. When user
stops the service, the work thread will exit from the loop and call
UnInitializeCom at last. The problem is there is always a series of
exception from VBVM60.dll when the work thread exit and is doing clean-up
work. If I try to stop the release version service in service control
manager, there will always be a dialog says:"...service can't stop
normally...".

It seems like some errors of COM library and VB COM dll clean-up, but I
didn't get any idea for several days. It's far beyond my knowledge. Does
anybody have similar experience or any idea?

Thanks lot ahead!

jeff



Sun, 26 Dec 2004 13:09:14 GMT  
 Atl NT service calling VB ActiveX dll had problem when clean-up
Hmm, not enought calls to ::SetServiceStatus comes to mind

Make sure you call ::SetServiceStatus periodically to notify
the service manager of the progress when stopping your service
(and when starting it). The code generated by the ATL wizard
is not incorrect in that area. Read more about services
in MSDN

  /claes


Quote:
> I have a NT service written by ATL in VC6.0sp5 on Win2000advsp2. My
service
> first lauchs a work thread then waits for user control message. The work
> thread will call a VB6.0 activeX dll, do some work in a loop. When user
> stops the service, the work thread will exit from the loop and call
> UnInitializeCom at last. The problem is there is always a series of
> exception from VBVM60.dll when the work thread exit and is doing clean-up
> work. If I try to stop the release version service in service control
> manager, there will always be a dialog says:"...service can't stop
> normally...".

> It seems like some errors of COM library and VB COM dll clean-up, but I
> didn't get any idea for several days. It's far beyond my knowledge. Does
> anybody have similar experience or any idea?

> Thanks lot ahead!

> jeff



Sun, 26 Dec 2004 15:32:39 GMT  
 Atl NT service calling VB ActiveX dll had problem when clean-up
Thanks, and more clues: I use COleDispatchDriver to wrap the VB COM dll, and
if the VB COM dll has not been created (like when the COM dll is not
registered at all), the service stops OK.
Error Info:
In debug mode: lots of "exception in MyService.exe: 0xC0000005: Access
Violation.".
    In code window, it become:  00000000    ???
                                                00000001    ???
                                                ...
In release mode(service control manager):  Error dialog title: Microsoft
Management Console
                                                                    Info:
Could not stop the MyService service on Local Comuter

Error 1067: The process terminated unexpectedly.
    However, after you close the error dialog, the service still can run
next time.

jeff


Quote:
> Hmm, not enought calls to ::SetServiceStatus comes to mind

> Make sure you call ::SetServiceStatus periodically to notify
> the service manager of the progress when stopping your service
> (and when starting it). The code generated by the ATL wizard
> is not incorrect in that area. Read more about services
> in MSDN

>   /claes



> > I have a NT service written by ATL in VC6.0sp5 on Win2000advsp2. My
> service
> > first lauchs a work thread then waits for user control message. The work
> > thread will call a VB6.0 activeX dll, do some work in a loop. When user
> > stops the service, the work thread will exit from the loop and call
> > UnInitializeCom at last. The problem is there is always a series of
> > exception from VBVM60.dll when the work thread exit and is doing
clean-up
> > work. If I try to stop the release version service in service control
> > manager, there will always be a dialog says:"...service can't stop
> > normally...".

> > It seems like some errors of COM library and VB COM dll clean-up, but I
> > didn't get any idea for several days. It's far beyond my knowledge. Does
> > anybody have similar experience or any idea?

> > Thanks lot ahead!

> > jeff



Mon, 27 Dec 2004 01:15:51 GMT  
 Atl NT service calling VB ActiveX dll had problem when clean-up
Sorry, a little more:  exceptions occur always right after "Info:
AfxDllCanUnloadNow returning S_OK"

=========================================================
Thanks, and more clues: I use COleDispatchDriver to wrap the VB COM dll, and
if the VB COM dll has not been created (like when the COM dll is not
registered at all), the service stops OK.
Error Info:
In debug mode: lots of "exception in MyService.exe: 0xC0000005: Access
Violation.".
    In code window, it become:  00000000    ???
                                                00000001    ???
                                                ...
In release mode(service control manager):  Error dialog title: Microsoft
Management Console
                                                                    Info:
Could not stop the MyService service on Local Comuter

Error 1067: The process terminated unexpectedly.
    However, after you close the error dialog, the service still can run
next time.

jeff



Mon, 27 Dec 2004 01:23:55 GMT  
 Atl NT service calling VB ActiveX dll had problem when clean-up
What Claes meant is that the ATL generated code is incorrect -
it does not specify valid checkpoints in SetServiceStatus for
SERVICE_STOP_PENDING notifications.

I notice you use MFC in your service. Note that MFC is officially
unsupported for use in services and it's a good idea not to use
it there.

When you start your service as a regular executable to debug
(or start it as a service and attach a de{*filter*} to it), go to Debug/
Exceptions and set the AccessViolation exception to always
break into the de{*filter*}. Then you'll see where things go
haywire (hopefully).

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.*-*-*.com/
=====================================

Quote:

> Sorry, a little more:  exceptions occur always right after "Info:
> AfxDllCanUnloadNow returning S_OK"

> =========================================================
> Thanks, and more clues: I use COleDispatchDriver to wrap the VB COM dll, and
> if the VB COM dll has not been created (like when the COM dll is not
> registered at all), the service stops OK.
> Error Info:
> In debug mode: lots of "exception in MyService.exe: 0xC0000005: Access
> Violation.".
>     In code window, it become:  00000000    ???
>                                                 00000001    ???
>                                                 ...
> In release mode(service control manager):  Error dialog title: Microsoft
> Management Console
>                                                                     Info:
> Could not stop the MyService service on Local Comuter

> Error 1067: The process terminated unexpectedly.
>     However, after you close the error dialog, the service still can run
> next time.

> jeff



Mon, 27 Dec 2004 02:06:01 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Problem in using VB Activex dll in Atl service

2. NT Service that loads a VB ActiveX DLL

3. Worker thread in ATL Service, call a VB DLL

4. Problem using ActiveX in ATL NT service.

5. ATL DLL event sink with a VB ActiveX DLL event source

6. Connection points between a VB COM-based and ATL COM-based (NT Service) MTA

7. Creating c dll calling vb ActiveX dll

8. Problem using VB 5 activex DLL in a VC++ activex control

9. ATL Service - Need to establish sink for a connection point of ActiveX dll

10. Calling VB dll or exe from Win32 Service

11. Calling VB dll or exe from Win32 Service

12. Debugging custom DLL called by NT service...

 

 
Powered by phpBB® Forum Software