A set of .NET Framework managed libraries for developing graphical user interfaces.
Hi @Mike Johnson ,
This message does not name the component involved, which makes it hard to trace from the error text alone. The call stack attached to the designer error is the most reliable place to start. On the Windows Forms Designer error page, expand the yellow error bar and select Show Call Stack for the error instance. The exception is thrown in ServiceContainer.AddService, so start at that top frame and read downward. The first caller from your solution or from a third-party assembly is normally the designer or component that triggered the second registration.
That caller does not need to call AddService itself. In a controlled test targeting .NET Framework 4.7.2 and running on 4.8.1, I got this exact exception from a custom designer derived from DocumentDesigner whose Initialize override called base.Initialize(component) twice. The base designer made the second registration, and the top of the stack was:
System.ComponentModel.Design.ServiceContainer.AddService(Type serviceType, ServiceCreatorCallback callback, Boolean promote)
System.Windows.Forms.Design.DocumentDesigner.Initialize(IComponent component)
Case6071074.BrokenDesigner.Initialize(IComponent component)
The screenshot below shows the full stack from that test host:
With the duplicate call removed, the same form loaded without errors and the host still supplied the event handler service. The test ran in a standalone DesignSurface host, not in Visual Studio, so it confirms one way to produce this message rather than the cause in your project. If your stack shows a custom or vendor designer directly under DocumentDesigner.Initialize or a similar base designer method, check whether that designer initializes more than once.
As for the snippet in the other answer, IEventHandlerService is internal in the .NET Framework System.Design assembly I tested, and typeof(IEventHandlerService) fails with CS0122, so that code does not compile as written.
If the stack contains only System and Microsoft.VisualStudio frames, or the caller is still unclear, feel free to post the full stack text with your Visual Studio version and target framework. I'm glad to take a look and help narrow down which component is involved.
I hope this helps you trace where the duplicate registration comes from. If it does lead you to the cause, I'd appreciate it if you could consider following this guidance, so others who run into the same error can find what worked more easily.
Thank you.