Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / September 2005

Tip: Looking for answers? Try searching our database.

Help: Window Service App Error - Need Win Service Expert Help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Van - 07 Sep 2005 01:06 GMT
Developing in C++, .Net 2003 (7.1)
Running on Windows XP SP2

My delima is that all my windows services run fine until I STOP the service
at which time I get a "The windows service terminated unexpectidly" and the
"Send error to microsoft window." I debugged through MY code and it appears
to clean itself up properly. I don't see any memory leaks. The error occurs
after my ServiceMain exits. I can't debug any further as it appears to be in
the kernel.dll.

Is there something special (not disclosed in the docs or examples) that I
must do to keep this from happening?

Here is the last lines of my ServiceMain:

 // Report our status one last time.
  ServiceStatus.dwCurrentState = SERVICE_STOPPED;
  ServiceStatus.dwWin32ExitCode = 0;
  ServiceStatus.dwCheckPoint += 1;
  ServiceStatus.dwWaitHint = 0;
  SetServiceStatus(hStatus, &ServiceStatus);
} // ServiceMain

And here is the message from the EventLog:

Faulting application OSSExecute.EXE, version 0.0.0.0, faulting module
unknown, version 0.0.0.0, fault address 0x0012e7dc.

This is really annoying me as I can't figure out what the cause is.... Any
help would be appreciated.
Van - 07 Sep 2005 11:45 GMT
FYI for those who find this post later.

The problem was my 'ServiceMain' function was *NOT* using the Windows API
calling convention. The MSDN documentation does show the calling convention
syntax however, the MSDN example (the one I have anyways) does NOT show using
the Windows API calling convention.

I had to change my ServiceMain function declaration from:

void ServiceMain(int argc, char* argv[])

to

VOID WINAPI ServiceMain(DWORD argc, LPSTR* argv)
   
and that fixed my problem.

Explaination (as it was told to me):

The calling method of 'void ServiceMain' is '__cdecl' and it does not clean
up on its own and thus was corrupting the stacks.

> Developing in C++, .Net 2003 (7.1)
> Running on Windows XP SP2
[quoted text clipped - 26 lines]
> This is really annoying me as I can't figure out what the cause is.... Any
> help would be appreciated.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.