I had completely forgotten about the Debug Assertion Failure when invoking the MFC CInternetSession from a console application.
I recently needed to teach an Old Dog a New Trick by performing an MFC FTP upload from a .NET (C#) console application.
When running the app in debug mode, I got the "Debug Assertion Failed" dialog box that requires an answer of Abort, Retry or Ignore.
I remembered (from long ago) this is a benign error and can just be ignored (if you want to press a button), but I didn't want any surprises and I wanted "clean" code.
In the rare instance someone else might run across this, here is the SHORT solution:
- Modify your header to include <afx.h>, <afxinet.h> and <afxwin.h>
- Add a module-level instance of CWinApp (yes, even in a console app).
- Set a value in your code for the variable afxCurrentAppName before invoking the CInternetSession
Here is the LONG solution
The error reported says there is a failure in the file afxwin1.inl at line 29.
After some disk searching, I found the file, afxwin1.inl, and saw the problem line 29:

...which simply checks to see if the variable afxCurrentAppName has a value.
afxCurrentAppName is an alias for AFX_MODULE_STATE::m_lpszCurrentAppName of type LPCTSTR in file afxstat_.h that is NOT automatically when making a console app (deeper explanation not given in this post).
Here's a test line of code that will cause the error:

Here is the dialog box showing the Debug Assertion Failure:

Here are the modifications to stop the error:
First, modify the header:

...then modify the code:

I have not run across any negative side-effects by doing this.