Microsoft KB Archive/216986

= BUG: QueryInterface Returning E_NOINTERFACE =

Article ID: 216986

Article Last Modified on 10/15/2002

-

APPLIES TO


 * Microsoft Visual SourceSafe 5.0 Standard Edition
 * Microsoft Visual SourceSafe 6.0 Standard Edition

-



This article was previously published under Q216986



SYMPTOMS
When creating OLE Automation in C that communicates with Microsoft Visual SourceSafe (VSS), if the program is created using VSS 5.0 OLE Automation and is then run on a computer that is using VSS 6.0, QueryInterface for versions can fail for the IID_IVSSVersion.



CAUSE
The VSS 6.0 Automation ignores the 5.0 IID_IVSSVersion.



RESOLUTION
If you have to create code that will run on computers using VSS 5.0 or VSS 6.0, see the following steps.  Follow the steps in:

HOWTO: Write automation for computers using VSS 5 or VSS 6.

 Create two separate programs and call the correct one based on what version of VSS the computer is using.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 Follow the steps in:

HOWTO: Open a SourceSafe Database with OLE Automation in C++

  Add the following code at the top of the program: #include <objbase.h>  #include <initguid.h>   #include <stdio.h>

#define MAKEHR(iStat) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF,(USHORT) (iStat)) </li>  Add the following code where the "// Add code here..." is: IVSSVersions* pVersions = NULL; IVSSVersion* pVersion = NULL; IVSSItem* pItem = NULL; IUnknown* pEnumerator = NULL; IEnumVARIANT* pVariant = NULL; Variant v;  unsigned long actual; int error, nointerface; BSTR Root = SysAllocString(L"$/");

VariantInit(&v); pVdb->get_VSSItem(Root, FALSE, &pItem); pItem->get_Versions(0, &pVersions); pVersions->_NewEnum(&pEnumerator); pEnumerator->QueryInterface(IID_IEnumVARIANT, (void **) &pVariant); pEnumerator->Release; pVariant->Next((unsigned long) 1, &v, &actual); error = v.pdispVal->QueryInterface(IID_IVSSVersion, (void **) &pVersion); nointerface = MAKEHR(E_NOINTERFACE); if (error == nointerface) printf("No Interface Error.\n"); </li> Compile and run the program. You should get an error number returned from the QueryInterface call with IID_IVSSVersion.</li></ol>

NOTE: This code should be created on a computer with VSS 5.0 and then run on a computer with VSS 6.0. If you want to create and run the program on a VSS 6.0 computer, use IID_IVSSVersionOld instead of IID_IVSSVersion.

Additional query words: OLE Automation

Keywords: kbbug kbautomation kbpending KB216986

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.