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:
Note The placeholders in this error message are as follows:
WebControlLibrary1
is a placeholder for the name of your namespace.WebCustomControl1
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.
MORE INFORMATION
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.
- Right-click IDictionary, point to Add, and then click Implement Interface.
- On the Build menu, click Build WebControlLibrary1.
You receive the error message that is mentioned in the "Symptoms" section of this article.
REFERENCES
For more information, visit the following Microsoft Developer Network (MSDN) Web sites:
IEnumerable Interface
http://msdn2.microsoft.com/en-us/library/system.collections.ienumerable(vs.71).aspx
Web Control Library Template
http://msdn2.microsoft.com/en-us/library/f3a1bsb5(vs.71).aspx
IDictionary Interface
http://msdn2.microsoft.com/en-us/library/system.collections.idictionary(vs.71).aspx
Compiler Error CS0535
http://msdn2.microsoft.com/en-us/library/525wxbha(vs.71).aspx
Compiler Error CS0536
http://msdn2.microsoft.com/en-us/library/ef306zxz(vs.71).aspx
Keywords: kbfix kbcodegen kbinheritance kbcontrol kbcollections kbclassview KB836127