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.
Tags: .NET, C#, Designer, IEventHandlerService, System.Windows.Forms.Design. IEventHandlerService, Visual Studio


April 9th, 2009 at 1:38 pm
work for me!
thanks
May 2nd, 2009 at 1:15 am
Yes.. it works by cleaning the OBJ folder manually..Thanks:))
May 7th, 2009 at 2:18 am
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?
June 14th, 2009 at 7:36 am
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!