PRB: Tlbexp.exe May Produce Invalid Method Declarations (317322)



The information in this article applies to:

  • Microsoft Windows .NET Framework 1.1
  • Microsoft .NET Framework 1.0

This article was previously published under Q317322

SYMPTOMS

When you use invalid or incompatible combinations of SafeArraySubType, Tlbexp.exe may produce invalid signatures for a method call.

CAUSE

Tlbexp.exe does not perform any validation before it produces the type library for the managed class.

STATUS

This behavior is by design.

MORE INFORMATION

For example, a managed class may implement the following interface:
public interface IAnimal
{
	void Eat([MarshalAs(UnmanagedType.SafeArray, SafeArraySubType=VarEnum.VT_CY)] string [] x);
	void EatSomeMore([MarshalAs(UnmanagedType.SafeArray, SafeArraySubType=VarEnum.VT_R8)] byte [] x);
}
				
When this managed class is exposed by using Tlbexp.exe, it produces the following type library definition for COM-based clients to consume:
interface IAnimal : IDispatch 
{
    [id(0x60020000)]
    HRESULT Eat([in] SAFEARRAY(CURRENCY) x);
    [id(0x60020001)]
    HRESULT EatSomeMore([in] SAFEARRAY(double) x);
};
				

Modification Type:MinorLast Reviewed:5/28/2003
Keywords:kbCOMInterop kbprb KB317322