For the last couple of days, I've been writing an ISAPI filter in C++. The experience has made me appreciate how much fun I've been having coding in C# for .NET, but that's another story.
There is a loose web-services side to my project, so I chose to make use of the ServerXMLHTTP object. This forced me to deal for the first time in a while with BSTRs and VARIANTS. The subject of this post is a problem I wrestled with, a VARIANT called vtMissing.
To ease debugging, I wrote a little console app to work out my ServerXMLHTTP code. In it, without thinking too much about it, I tried using a VARIANT with the tag VT_UNKNOWN for vtMissing. My console app worked, so I didn't worry about it.
But when I plugged the code into the ISAPI filter, my synchronous send call failed right away with a return code of 0xc0000005L (STATUS_ACCESS_VIOLATION). After messing with several more obvious possibilities for the cause of the problem, I finally turned to vtMissing. It took a bit of detective work, but here's what I found (at least this change made my code run). vtMissing should have the tag VT_ERROR and the long value DISP_E_PARAMNOTFOUND (0x80020004L).
I'm posting this mostly to get it into Googlespace so the next poor programmer trying to interface to VB-friendly code can find it more easily than I did. Please, anyone in the know, if this is incorrect, let me know and I'll report it here. My best evidence that it is correct is that with it my code works.
2:36:15 PM
|