If you encounter this warning while compiling a Windows Form application in Visual Studio:

The service System.Windows.Forms.Design.IEventHandlerService already exists in the service container. Parameter name: serviceType

The solution is not very obvious, and the help provides no guidance.  After a little experimenting, I discovered an easy solution:

  1. Exit Visual Studio.
  2. Open Explorer, and navigate to the folder that contains your project.
  3. Delete the “bin” and “obj” folders.
  4. Restart Visual Studio, load your project and re-compile.  The error should be gone.

This problem occurred when I attempted to inherit a derived Form from a class other than Form.  When I changed it back to once again inherit from Form, the warning appeared.

You need to exit Visual Studio because you cannot delete the folders while the project is open.

Popularity: 7% [?]

Related posts:

  1. Visual Studio 2008 and .NET 3.5 Service Pack 1 Released
  2. Adding Assemblies to the Visual Studio "Add Reference" Dialog
  3. Web Service Stumper: "Ambiguous Type"
  4. Close All Forms in an Application in a Thread-Safe Manner
  5. Hide Visual Studio Macro Balloon