Stupid ISAPI filter! I hate unmanaged code!

I have been spoiled by managed code, I know it. As some may know, I am currently writing / modeling an ISAPI filter that rides in front of SharePoint (or rides in front of all web appplications through the virtual server by virtual server configuration) that negates the need for extranet mode. It is meant to take existing web application authentication schemes (whatever you use like NTLM or Kerberos) and wrap them in my custom protocol which is coded to traverse persistently between web applications and MS Office clients. I am using the OpenSSL library in order to handle the cryptographic schemes, and fortunatly I remember enough VC++ (even though I was experimenting with some other filters written in C) to properly code it.

So clearly with this filter a majority of the code handles and massages the global server variables as they are passed back and forth from SharePoint like _User and _Credentials. I got it working fine, however every 100th or so request I get this:

The HTTP Filter DLL C:\WINDOWS\system32\inetsrv\arbsecuritysolutions\SharePointAuth.dll failed to load.  The data is the error.

Well, that isn’t tremoundsly descriptive. The data is the error?

Looking a little further in the event log, there is also this error logged:

Could not load all ISAPI filters for site/service.  Therefore startup aborted

This keeps getting better. I really hate not having the system.diagonastics namespace.

So stepping back now I am looking again and the ISAPI application request flow that goes from calling the ISAPI compiled image, to verifying the GetFilterVersion() and HttpFilterProc() entry points which if fail look to write to the event log through the GetLastErrors() method which should return the last error string.

I will post the solution once I find it, but I would just like to express that I really hate unmanaged code.