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.

Share and Enjoy:
  • Digg
  • Twitter
  • Facebook
  • Reddit
  • StumbleUpon
  • LinkedIn
  • Google Bookmarks
  • Slashdot