I have an application (ATL C++ using MFC through dll) which is a tcp/ip simple web server. This web server calls a C# dll to do some encryption (RSA/MD5). When logging out of the workstation the below error is displayed. If I stop the application in any other way I do not receive this error - only if it is running at logout does this dialog box get displayed.

I use a lot of strings (STD::string) in this program if that makes a difference.

Code:
Application popup: MayoCCOW.exe - Application Error : The instruction at "0x79442e83" referenced memory at "0x02f11660". The memory could not be "written".

Click on OK to terminate the program

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
I have walked through the code and done everything I can find on Microsofts website. Unfortunately I cannot debug the code because at logout of the workstation everything else goes away except this error, including the debugger.

Can anyone help me or guide me in what I can do to fix this? Your help is greatly appreciated!