Windows Service (.NET) and MFC

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kieferzhen
    New Member
    • Jul 2008
    • 3

    Windows Service (.NET) and MFC

    I want to write a windows service (myService) by using C++/CLI (Visual Studio 2005). This myService can use MFC function for OLE Automation.

    Just for a first try, I did the following project configuration and coding:

    • Creating a Windows Service under C++/CRL
    • Adding ServiceInstalle r with start type automatic and sereviceprocess Installer with Account Local System
    • Setting MFC in a Shared DLL
    • Setting Common Language Runtime Support (/clr)
    • Setting Multithreaded-Debug-DLL (/MDd)
    • Adding #include <afxdisp.h> in stdafx.h

    Compile is always successful. But when I use myServie.exe –Install to install my windows service in Visual Studio 2005 Command Prompt, I always get the following exceptions

    When debugging:
    Unhandled exception at 0x78374588 (mfc80ud.dll) in myService.exe: 0xC0000005: Access Violation reading location 0x00000000.

    In Visual Studio 2005 Command Prompt:
    Unhandled exception: System.AccessVi olationExceptio n
    Attempted to read or write protected memory.
    This is often an indication that other memory is corrupt.
    at _wWinMainCRTSta rtup()

    Does anyone know the reason? Where am I wrong?

    Many thanks for any help!
Working...