BUG: COM Client Method Call Fails with ERROR_NOACCESS (273721)



The information in this article applies to:

  • Microsoft COM

This article was previously published under Q273721

SYMPTOMS

If you use the Microsoft Interface Definition Language (MIDL) option /Oicg to generate the proxy stub code, the COM client's method call fails with ERROR_NOACCESS. You may also receive an Access Violation (0xC0000005) in the stub code. This happens only when you use the MIDL-generated proxy stub dynamic-link library (DLL) to marshal, and there is an empty interface (with no methods in it) in an interface hierarchy.

NOTE: This problem does not occur when the /Os flag is used to generate proxy stub code. However, /Oicf is the only option that supports certain new features of the MIDL compiler.

RESOLUTION

There are two ways to work around this problem:
  • Do not use an empty interface.
  • If possible, use the /Os flag for MIDL.

STATUS

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

MORE INFORMATION

Steps to Reproduce Behavior

  1. The IDL file should include the following code:
    ...
    typedef [unique] IBar* LPBAR;
    [
    	object,
    	uuid(abcdef00-9f33-11cd-b23f-067534339cce),
    	pointer_default(unique)
    ]
    interface IHello : IUnknown
    {
        HRESULT Get([out] LPCAT* pCat);
    }
    
    [
    	object,
    	uuid(abcdef11-9f33-11cd-b23f-067534339cce)
    ]
    interface IMammal : IUnknown
    {
        HRESULT DoSomething([in] BSTR pszString);
    }
    
    [
    	object,
    	uuid(abcdef22-9f33-11cd-b23f-056437769cce)
    ]
    interface ICat : IMammal
    {
    	//Empty interface with no methods in it.
    }
    ...
    					
  2. The COM client should include the following code:
    ...
    LPBAR pBar = NULL;
    hr = pHello->Get(&pCat);
    
    if(SUCCEEDED(hr))
    {
        hr = pCat->DoSomething(OLESTR("Bar"));
    }
    ...
    						
    The above call to pCat->DoSomething fails with ERROR_NOACCESS.

Modification Type:MajorLast Reviewed:7/12/2001
Keywords:kbbug kbDSupport KB273721