Okay, I came across this error today:

Warning 1 

The service System.Windows.Forms.Design.IEventHandlerService already exists in the service container.

Parameter name: serviceType

and it took me a while to find the solution. In my case, and I say this because I’m not sure if this will work in your case… the solution was as simple as cleaning the OBJ folder manually.

Other tip I can give you in case the previous one doesn’t work for you , is to add the following line to all your form Load events:

if (DesignMode) return;

However, in my case, cleaning the OBJ folder, was what brought peace and mental sanity back to me.

Feel free to post your experiences/solutions, so others can recover their peace of mind as well.

 
Sphere: Related Content

Tags: , , , , ,

4 Responses to “System.Windows.Forms.Design. IEventHandlerService already exists in the service container”

  1. work for me!
    thanks

  2. Yes.. it works by cleaning the OBJ folder manually..Thanks:))

  3. hello ….. your solution works for standard windows applications but how you overcome this problem when your application targets mobile devices. In this situation you dont have a “DesignMode”.
    I cleaned the obj folder manually but still …..
    Any idea?

  4. Thanks for the tip, this helped. Even a full Clean/Rebuild didn’t do the trick, but cleaning the obj folder did the trick.

    I have found that the DesignMode flag is not reliable. In certain circumstances, I resort to getting the current process and compare its name to my application’s name.

    Process p = Process.GetCurrentProcess();
    if (p.ProcessName!= “MyApplicationName)
    {
    return;
    }

    Helps most of the time, but occasionally I get stuck and have to find the right place to put conditional code.

    It is especially important to put be careful what goes into the constructor(s) as well.

    Thanks again!

Leave a Reply