-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
Milestone
Description
Description
My server object implements two interfaces with one being default.
I can access members of the default interface but not of the non-default one.
Instead, I get Unknown name. (0x80020006 (DISP_E_UNKNOWNNAME)) on such access.
Reproduction Steps
My server exposes such COM object:
[ComVisible(true)]
[CLSCompliant(true)]
[ProgId("MyCompany.MyObject")]
[Guid("{CF824E95-642E-4F8D-8CD1-F67BC588B107}")]
[ClassInterface(ClassInterfaceType.None)]
[ComDefaultInterface(typeof(IFirst))]
public sealed class MyObject : IFirst, ISecond
{
public void Invoke1() {}
public void Invoke2() {}
}
[ComVisible(true)]
[CLSCompliant(true)]
[Guid("{59DAED5B-726B-4DDD-8F07-9236382038F7}")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IFirst
{
void Invoke1();
}
[ComVisible(true)]
[Guid("{88C3FF65-0155-48A9-917D-E96DFAC8409B}")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface ISecond
{
void Invoke2();
}My client does this:
var myObjectType = Type.GetTypeFromProgID("MyCompany.MyObject", throwOnError: true)!;
dynamic first = Activator.CreateInstance(myObjectType);
first.Invoke1(); // works well
var second = (ISecond)first; // get to an explicit interface implementation
second.Invoke2(); // throws COMException with DISP_E_UNKNOWNNAMEI followed a solution from "Custom wrappers" section of Generating Metadata.
Expected behavior
I can access members of non-default interfaces of COM objects.
Actual behavior
I get COMException with DISP_E_UNKNOWNNAME on access of non-default interface members of COM objects.
Regression?
Works in .NET Framework and .NET 8. Not working since .NET 9.
Known Workarounds
No response
Configuration
Windows 11
.NET 8.0.404
.NET 9.0.308
.NET 10.0.100
Other information
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status