Microsoft KB Archive/317626

= PRB: Overloaded Methods in a .NET Component May Not Be Version-Compatible for Unmanaged Clients =

Article ID: 317626

Article Last Modified on 2/23/2007

-

APPLIES TO


 * Microsoft .NET Framework 1.1
 * Microsoft .NET Framework 1.0

-



This article was previously published under Q317626



SYMPTOMS
If a managed component has an interface that contains overloaded methods, and you update the component with more overloaded methods, the methods may no longer be version-compatible for an unmanaged client. This may break existing COM (that is, unmanaged) clients.



CAUSE
Components with overloaded methods are exposed to unmanaged clients as, where   varies from two to the total number of overloads for that specific method. If you add a new overloaded method, the numbering scheme may generate a different name for the same method.



STATUS
This behavior is by design.



MORE INFORMATION
If the managed component has an interface with the following overloaded members void TestMethod(short a); void TestMethod(long a); void TestMethod(string a); these methods are exposed to the unmanaged client (that is, the COM client) respectively as the following: HRESULT TestMethod(short a); HRESULT TestMethod_2(__int64 a); HRESULT TestMethod_3(BSTR a); If you add another overloaded method to update this component, and if the method is added between the existing methods in order, as follows void TestMethod(short a); void TestMethod(int a); void TestMethod(long a); void TestMethod(string a); the class is exposed to the unmanaged client respectively as the following: HRESULT TestMethod(short a); HRESULT TestMethod_2(long a); HRESULT TestMethod_3(__int64 a); HRESULT TestMethod_4(BSTR a); This change is version-compatible in a managed client. However, for an unmanaged client, these methods are unintuitive and are not version compatible.

In the example, initially void TestMethod(long a); is exposed to the unmanaged client as the following: HRESULT TestMethod_2(__int64 a); When you add a new overloaded method to update this component, the same method in the component is exposed to the unmanaged client as the following: HRESULT TestMethod_3(__int64 a);

Keywords: kbcominterop kbprb KB317626

-

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

© Microsoft Corporation. All rights reserved.