Please help on this strange Windows service only exception

  • Thread starter Thread starter zhongsheng
  • Start date Start date
Z

zhongsheng

Guest
Hi,



I used to use Visual Studio 6.3 to develop my application. The application is running as a Windows service on Windows XP SP2. This was working for so many years.



Now I want to compile my application in Visual Studio 2005 SP1 with Manifect generation enabled. The conversion seems to be ok. However, I run into one weird problem with Windows service.



When I disable the service from Service Control Manager, I was able to run my application all the way to the end without any warning.



When I enable the service, I will get exception immidiately after service starts. The stack trace indicates the problem is related to this:



EXCEPTION_RECORD: ffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 782620c8 (mfc80d!AfxWinMain+0x00000078)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 00000000
Parameter[1]: 00000000
Attempt to read from address 00000000

DEFAULT_BUCKET_ID: NULL_POINTER_READ

Stack:



026cff3c 005d9d7b 00400000 00000000 0015234a mfc80d!AfxWinMain+0x78



Attach VS 2005 to the process shows the stack at:




BOOL CWinApp::_LoadSysPolicies()
throw()

{


...




_AfxSysPolicies *pPolicies = rgPolicies;

_AfxSysPolicyData *pData = NULL;

while (pPolicies->szPolicyKey != NULL)

{

if (ERROR_SUCCESS == ::RegOpenKeyEx( <- This line crashes

HKEY_CURRENT_USER,

pPolicies->szPolicyKey,

NULL,

KEY_QUERY_VALUE,

&hkPolicy

))

.....​

}​


This function is called in InitApplication() which is called by AfxWinMain().


I need to fix this problem, but I don't have much clue why this is happening. Could it be possible that Windows Service does not like SxS MFC DLL? or some initialization step is required to run an application in Windows service if Manifest is used?​


Anyway, I don't have a clue yet. I hope some gurus there can help me to resolve this.​


Thanks,​


zhongsheng​

Continue reading...
 
Back
Top