Microsoft KB Archive/836127

= FIX: You receive the &quot;Does not implement interface member 'System.Collections.IEnumerable.GetEnumerator'&quot; error message when you try to build a Web Control Library project =

Article ID: 836127

Article Last Modified on 5/17/2007

-

APPLIES TO


 * Microsoft Visual C# .NET 2002 Standard Edition

-



SYMPTOMS
You receive an error message when you try to build a Web Control Library project in Microsoft Visual C# .NET 2002. Specifically, if the project contains a Web server control that implements the IDictionary interface, you receive an error message after the Implement Interface command runs. The error message that you receive may be similar to the following:

. ' does not implement interface member 'System.Collections.IEnumerable.GetEnumerator'. ' . .GetEnumerator' is either static, not public, or has the wrong return type.

Note The placeholders in this error message are as follows:
 * is a placeholder for the name of your namespace.
 * is a placeholder for the class name of your Web server control.



CAUSE
In Visual C# .NET 2002, the Implement Interface command does not implement all methods of an interface if any other methods that have the same name and parameters exist in another interface that a class implements. This behavior occurs although the methods may have different return data types.

For example, the Implement Interface command implements the GetEnumerator method of the IDictionary interface. However, the Implement Interface command does not implement the GetEnumerator method of the IEnumerable interface, although the methods have different return data types. Therefore, you experience the symptoms that are described in this article.



RESOLUTION
To resolve this behavior, add the following code to your Web server control class file after the code that the Implement Interface command generates: System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator {   return null; }



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in Microsoft Visual C# .NET 2003.



Generic scenario
In Visual C# .NET 2002, the Implement Interface command does not implement all methods of an interface if any other methods that have the same name and parameters exist in another interface that a class implements. Therefore, some methods of interfaces that the class inherits from may not be implemented. Therefore, when you try to build a project that contains such a class, you may receive an error message.

For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

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

Steps to reproduce the behavior
 Start Visual Studio .NET 2002. Use Visual C# .NET to create a Web Control Library project. By default, the WebControlLibrary1 project is created together with the WebCustomControl1.cs file.  In the WebCustomControl1.cs file, locate the following code: public class WebCustomControl1 : System.Web.UI.WebControls.WebControl   Replace the code that you located in the previous step with the following code so that your Web server control also inherits from the IDictionary interface: public class WebCustomControl1 : System.Web.UI.WebControls.WebControl, System.Collections.IDictionary  Open Class View. Expand WebControlLibrary1, expand WebControlLibrary1, expand WebCustomControl1, and then expand Bases and Interfaces.</li> Right-click IDictionary, point to Add, and then click Implement Interface.</li> On the Build menu, click Build WebControlLibrary1.

You receive the error message that is mentioned in the &quot;Symptoms&quot; section of this article.</li></ol>

<div class="references_section">