I write an outlook addin in C# and it invokes a cli c++ dll.
In the dll, it fails to invoke webservice method in some machines of windows 7.
I debug and find error codes in atlspriv.inl and atlhttp.ini.
I think it's thread
synchronization.I fixed it by modifying microsoft codes.solution is as follows:
Syncdatacomponentdll fail to call webservice method in some machines of windows 7.This is a Microsoft bug. It’s related to thread synchronization.
The Error codes are in the files of vs2005. So please modify them.
1.
%intallpath%(such as C:\Program Files\Microsoft Visual Studio 8) \VC\atlmfc\include\atlhttp.inl
Function: inline
bool CAtlHttpClientT<TSocketClass>::ReadSocket()
throw()
Source error codes:
if (!bRet)
return bRet;
Correct codes:
//fix microsoft bug happen in some machine of windows 7!
if (!bRet)
{
int nNum = 0;
while(nNum<30)
{
Sleep(1000);
bRet = Read(read_buff, (DWORD*)&dwSize);
if(bRet)
break;
nNum++;
}
if (!bRet)
return bRet;
}
Function: inline
typename CAtlHttpClientT<TSocketClass>::HTTP_RESPONSE_READ_STATUS CAtlHttpClientT<TSocketClass>::ReadHttpResponse()
Source error codes:
pBodyBegin = FindHeaderEnd(&pHeaderBegin);
if (!pBodyBegin)
{
Correct codes:
pBodyBegin = FindHeaderEnd(&pHeaderBegin);
if (!pBodyBegin)
{
//fix microsoft bug happen in some machine of windows 7!
Sleep(10000);
2.
%intallpath%(such as C:\Program Files\Microsoft Visual Studio 8) \VC\atlmfc\include\ atlspriv.inl
Function:
inline
bool ZEvtSyncSocket::Connect(const SOCKADDR* psa,
int len)
Source error codes:
dwLastError = WSAGetLastError();
if (dwLastError != WSAEWOULDBLOCK)
{
m_dwLastError = dwLastError;
bRet = false;
}
Correct codes:
//fix microsoft bug happen in some machine of windows 7!
DWORD dwLastError2 = GetLastError();
dwLastError = WSAGetLastError();
if (dwLastError != WSAEWOULDBLOCK&&dwLastError2 != WSAEWOULDBLOCK)
{
m_dwLastError = dwLastError;
bRet = false;
}
But I think it's not a perfect solution. Does anybody meet the problem and find perfect solution?
I am looking forward to your reply.thanks!