Microsoft KB Archive/316581

= BUG: Compile error message when you implement a class in a referenced COM library =

Article ID: 316581

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Visual Basic 2005 Express Edition
 * Microsoft Visual Basic .NET 2003 Standard Edition
 * Microsoft Visual Basic .NET 2002 Standard Edition

-



This article was previously published under Q316581



SYMPTOMS
When you implement a class in a referenced Component Object Model (COM) library in Visual Basic .NET or in Visual Basic 2005, you receive the following compile error message:

must implement 'Overridable Overloads Property  As Object' for interface. '. Implementing property must have matching 'ReadOnly'/'WriteOnly' specifiers.

' ' cannot implement  because there is no matching property on interface ' '.



CAUSE
This behavior occurs because a class in the COM library exposes one or more public variant variables, or it exposes a public Property Let or Property Set procedure that passes arguments by reference.



RESOLUTION
To resolve this bug, rebuild the COM library so that it passes arguments to property procedures by value instead of by reference, as in the following sample code: Public Property Let Data(ByVal strDataIn As String) strData = strDataIn End Property



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the &quot;Applies to&quot; section.



Steps to Reproduce the Problem
 Start Microsoft Visual Basic 6.0. Create a new ActiveX DLL project.  Type the following code in the General Declarations section of the default class module, Class1: Private strData As String

Public Property Get Data As String Data = strData End Property

Public Property Let Data(strDataIn As String) 'Note that the strDataIn argument is being passed 'by reference because neither the ByRef and ByVal keywords 'have been declared.

strData = strDataIn End Property  On the File menu, click Make Project1.DLL. Select a location in which to create the project, and then click OK.</li> Start Microsoft Visual Studio .NET or Microsoft Visual Studio 2005.</li> Create a new Visual Basic Class Library project.</li> On the Project menu, click Add Reference.</li> On the COM tab, select the Project1 component, click Select, and then click OK.

Note In Visual Studio 2005, you do not have to click Select.</li>  Add the following code to the default Class1 class module: Public Class Class1 Implements Project1.Class1 'Implements this COM class

End Class </li> In the Class Name list on the left side of the code window, click Class1 (Project1).</li>  In the Method Name list on the right side of the code window, click Data.

This automatically adds the following code to the class module to provide the implementation for the Data property: Public Property Data As String Implements Project1.Class1.Data Get End Get

Set (ByVal Value As String) End Set End Property </li> On the Build menu, click Build Solution. Note the following build errors displayed in the Task list:

'ClassLibrary1.Class1' must implement 'Overridable Overloads Property Data As String' for interface 'Project1._Class1'. Implementing property must have matching 'ReadOnly'/'WriteOnly' specifiers.

'Data' cannot implement 'Data' because there is no matching property on interface 'Class1'.

</li></ol>

Keywords: kbvs2005swept kbvs2005applies kbvs2002sp1sweep kbbug kberrmsg kbnofix KB316581

-

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

© Microsoft Corporation. All rights reserved.