Skip to content

InterfaceSupportsErrorInfo called with CLSID instead of an IID #121252

@JosephSchreiner

Description

@JosephSchreiner

Description

Pull request 117690 introduces a change where COM objects that implement ISupportErrorInfo have InterfaceSupportsErrorInfo called with the COM object class id instead of an interface id.

Specifically, the logic at https://github.com/dotnet/runtime/pull/117690/files#diff-c10abbd9bedf89c7a6ea5ace199b19ac17564e0e1e8583cd22b05546d18e0789L591-L609. The look up there first "unwraps" the calling method and then uses the associated type with that method (that is, the interface type).

The missing logic in the above is the call to CLRToComCallInfo::FromMethodDesc -

// static
inline CLRToCOMCallInfo *CLRToCOMCallInfo::FromMethodDesc(MethodDesc *pMD)
{
LIMITED_METHOD_CONTRACT;
if (pMD->IsCLRToCOMCall())
{
return ((CLRToCOMCallMethodDesc *)pMD)->m_pCLRToCOMCallInfo;
}
else
{
_ASSERTE(pMD->IsEEImpl());
return ((DelegateEEClass *)pMD->GetClass())->m_pCLRToCOMCallInfo;
}
}
. The new logic is much more naive and doesn't examine the MethodDesc properly -
RuntimeMethodHandle handle = RuntimeMethodHandle.FromIntPtr(pCPCMD);
RuntimeType declaringType = RuntimeMethodHandle.GetDeclaringType(handle.GetMethodInfo());
.

Reproduction Steps

  1. In a non-.NET language, write a COM object that implements the ISupportErrorInfo interface. Include a method call that will fail with a known error message. Within InterfaceSupportsErrorInfo debug print the riid provided.
  2. Within a C# application, instantiate the COM object and call the method that is known to fail.
  3. Observe that the known error message is lost.
  4. Observe that the debug print statement indicates that InterfaceSupportsErrorInfo was called with the class id instead of an interface id.

Expected behavior

InterfaceSupportsErrorInfo is called with an interface id.

Actual behavior

InterfaceSupportsErrorInfo is called with a class id.

Regression?

Known to work in .NET SDK 9.0.306
Known to not work in .NET SDK 10.0.100-rc.2.25502.107

Known Workarounds

None

Configuration

.NET SDK 10.0.100-rc.2.25502.107
Microsoft Windows 10 Enterprise LTSC 10.0.17763 Build 17763 (but also known to be an issue on Windows 11)
Architecture: Windows x64, application x86
It is not believed that the problem is specific to this configuration.

Other information

No response

Metadata

Metadata

Type

No type

Projects

Status

No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions