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:
- Exit Visual Studio.
- Open Explorer, and navigate to the folder that contains your project.
- Delete the “bin” and “obj” folders.
- 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.