Microsoft KB Archive/811601

= BUG: The Visual C# .NET Implement Interface command does not implement different declarations with the same signature =

Article ID: 811601

Article Last Modified on 1/18/2006

-

APPLIES TO


 * Microsoft Visual C# .NET 2002 Standard Edition

-



SYMPTOMS
The Microsoft Visual C# .NET Implement Interface command does not implement functions that have the same signature. However, the return types of the functions are different when you implement more than one interface. You may receive the following compilation error message when you try to build the project:

NameSpace.Class Name does not implement interface member Member Name'. NameSpace.ClassName.Member Name is either static, not public, or has wrong return type.

Where Class Name is the name of the class and Member Name is the name of the method with the same signature.



CAUSE
In Microsoft Visual Studio .NET 2002, the Implement Interface command does not implement all the functions of an interface if any other function with the same signature already exists (even if the functions have different return types) in another interface that is implemented by the class. As a result, some of the functions with the same signature are not implemented when you use the Implement Interface command. Therefore, you may receive a compilation error when you try to compile your project.



WORKAROUND
To work around this problem, manually add the implementation of the function that was not implemented by the Implement Interface command.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug had been fixed in Microsoft Visual Studio .NET 2003.



MORE INFORMATION
Steps to Reproduce the Behavior  Create a new Microsoft Visual C# .NET Console Application Project, and name the project TestApplication. By default, Class1.cs is created.  Replace the code of the Class1.cs with the following code: using System;

namespace TestApplication {   interface I1    { int Function1; }   interface I2    { int Function2; float Function1; }   class Class1:I1,I2 {       [STAThread] static void Main(string[] args) {           Console.WriteLine(&quot;Test Application&quot;); }   } }  Class1 implements I1 and I2 interfaces.  On the View menu, click Class View. Expand TestApplication, expand Class1, and then expand Bases and Interfaces. Interface I1 and Interface I2 are displayed. To add implementation of Interface I1 to Class1, right-click Interface I1, point to Add, and then click Implement Interface. To add implementation of Interface I2 to Class1, right-click Interface I2, point to Add, and then click Implement Interface. This only implements the Function2 function for Interface I2. The Function1 function for Interface I2 is not implemented.</li> On the Build menu, click Build Solution to compile the project. You receive the error message that is described in the &quot;Symptoms&quot; section of this article.</li>  To build the project successfully, manually implement the missing function of Interface I2. To do this, add the following code to Class1: float I2.Function1 {           return 0; } </li> Repeat step 8 to successfully build the project.</li></ol>

Keywords: kberrmsg kbbug kbmsg kbcompiler kbinheritance KB811601

-

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

© Microsoft Corporation. All rights reserved.