question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DesignerHost.CreateComponent throws NotImplemetedException

See original GitHub issue
  • .NET Core Version:

.NET SDK 5.0.101 - .NET Framework 5.0

  • Have you experienced this same bug with .NET Framework?:

No, the bug does not happen in .NET 4.8

Problem description: DesignerHost.CreateComponent throws NotImplemetedException with message: This method/object is not implemented by design.

System.Windows.Forms.Design.dll!System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.CreateComponent(System.Type componentType, string name) Line 712	C#
 	System.Windows.Forms.Design.dll!System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.CreateComponent(System.Type componentType) Line 682	C#
 	System.Windows.Forms.Design.dll!System.ComponentModel.Design.DesignSurface.DefaultDesignerLoader.BeginLoad(System.ComponentModel.Design.Serialization.IDesignerLoaderHost loaderHost) Line 329	C#
 	System.Windows.Forms.Design.dll!System.ComponentModel.Design.DesignerHost.BeginLoad(System.ComponentModel.Design.Serialization.DesignerLoader loader) Line 239	C#
 	System.Windows.Forms.Design.dll!System.ComponentModel.Design.DesignSurface.BeginLoad(System.ComponentModel.Design.Serialization.DesignerLoader loader) Line 123	C#
 	System.Windows.Forms.Design.dll!System.ComponentModel.Design.DesignSurface.BeginLoad(System.Type rootComponentType) Line 132	C#
 	DesignSurfaceExtNet5.dll!DesignSurfaceExtNet5.DesignSurfaceExt.CreateRootComponent(System.Type controlType, System.Drawing.Size controlSize) Line 107	C#
 	DemoConsoleNet5.dll!DemoConsoleNet5.MainForm.CreateDesignSurface(int n) Line 108	C#
 	DemoConsoleNet5.dll!DemoConsoleNet5.MainForm.InitFormDesigner() Line 29	C#
 	DemoConsoleNet5.dll!DemoConsoleNet5.MainForm.MainForm_Load(object sender, System.EventArgs e) Line 239	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Form.OnLoad(System.EventArgs e) Line 2625	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Form.OnCreateControl() Line 2501	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.CreateControl(bool fIgnoreVisible) Line 3548	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.CreateControl() Line 3513	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.WmShowWindow(ref System.Windows.Forms.Message m) Line 8348	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) Line 8461	C#
 	System.Windows.Forms.dll!System.Windows.Forms.ScrollableControl.WndProc(ref System.Windows.Forms.Message m) Line 998	C#
 	System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.WndProc(ref System.Windows.Forms.Message m) Line 1195	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Form.WmShowWindow(ref System.Windows.Forms.Message m) Line 4189	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Form.WndProc(ref System.Windows.Forms.Message m) Line 4280	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) Line 12276	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) Line 12304	C#
 	System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, Interop.User32.WM msg, System.IntPtr wparam, System.IntPtr lparam) Line 196	C#
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	System.Windows.Forms.dll!System.Windows.Forms.Control.SetVisibleCore(bool value) Line 7347	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Form.SetVisibleCore(bool value) Line 1491	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Interop.Mso.msoloop reason, System.Windows.Forms.ApplicationContext context) Line 1929	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Interop.Mso.msoloop reason, System.Windows.Forms.ApplicationContext context) Line 1867	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Application.RunDialog(System.Windows.Forms.Form form) Line 794	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Form.ShowDialog(System.Windows.Forms.IWin32Window owner) Line 3514	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Form.ShowDialog() Line 3453	C#
 	DemoConsoleNet5.dll!DemoConsoleNet5.Program.Main(string[] args) Line 42	C#

I am porting from .NET 4.8 to 5.0 a report designer that features a drag and drop design surface and uses WinForms. Everything works except for this. I also ported from .NET 3.5 to 5.0 this project (https://www.codeproject.com/Articles/24385/Have-a-Great-DesignTime-Experience-with-a-Powerful) and everything works except for this. Using dotPeek to step into the .NET 5.0 code I got as far as DesignerHost.CreateComponent, but I didn’t find the method that throws the exception.

Expected behavior: DesignerHost.CreateComponent returns the requested component

Minimal repro:

  1. create a Windows Forms App using .NET 5.0 Framewok
  2. create a class DesignSurfaceExt that inherits System.ComponentModel.Design.DesignSurface
  3. initialize DesignSurfaceExt by calling ServiceContainer.AddService(typeof(INameCreationService), _nameCreationService);
  4. call rootComponent = (Form)designSurfaceExt.CreateRootComponent(typeof(Form), new Size(640, 480)); expected: CreateRootComponent returns a new Form actual: DesignerHost.CreateComponent throws NotImplemetedException with message ‘This method/object is not implemented by design.’

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
RussKiecommented, Apr 19, 2021

The progress is slow, but I’ve managed to get https://www.codeproject.com/Articles/24385/Have-a-Great-DesignTime-Experience-with-a-Powerful to the basic render stage: image

1reaction
merriemcgawcommented, Feb 9, 2021

I do believe we should port this to the runtime sometime in the .NET 6 timeframe. @dreddy-work and @RussKie as FYI to try to get it scheduled - perhaps in a soon to come Preview?

Read more comments on GitHub >

github_iconTop Results From Across the Web

DocumentDesigner class is not implemented. What support ...
Design such as IDesignerHost, IDesignerEventService, etc. ... DesignerHost.CreateComponent throws NotImplemetedException #4456.
Read more >
c# - Implement interface includes throw new ...
So, I know this is an old question, but it looks like Visual Studio 2017 now allows you to choose between the two...
Read more >
Winforms Designer error when using new SDK style project ...
Create new NET Framework 4.7.2 class library project (not new SDK ... the built-in license check features throws a NotImplementedException, ...
Read more >
NotImplementedException Class (System)
The NotImplementedException exception is thrown when a particular method, get accessor, or set accessor is present as a member of a type but...
Read more >
Use of NotImplementedException
I am the "hard error" type of guy: I will throw an exception at the slightest hint that something might be wrong; I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found