Can't understand this exception at design time

Tech-Archive recommends: Speed Up your PC by fixing your registry



Hi,

I'm writing a custom control and I face a strange problem since I have
the latest release of Visual C# express 2005.

When I drag the control from the toolbox to a form, I get this
exception:

Failed to create component. The error message follows:
'System.NullReferenceException: Object reference not set to an instance
of an object. at
System.Windows.Forms.NativeWindow.AddWindowToTable(IntPtr handle,
NativeWindow window) at
System.Windows.Forms.NativeWindow.AssignHandle(IntPtr handle, Boolean
ssignUniqueID) at
System.Windows.Forms.NativeWindow.AssignHandle(IntPtr handle) at
System.Windows.Forms.Design.ControlDesigner.ChildSubClass..ctor(ControlD
esigner designer, IntPtr hwnd) at
System.Windows.Forms.Design.ControlDesigner.HookChildHandles(IntPtr
firstChild) at
System.Windows.Forms.Design.ControlDesigner.HookChildControls(Control
firstChild) at
System.Windows.Forms.Design.ControlDesigner.OnHandleChange() at
System.Windows.Forms.Design.ControlDesigner.DesignerWindowTarget.OnHandleChange(IntPtr
newHandle) at
System.Windows.Forms.Control.ControlNativeWindow.OnHandleChange() at
System.Windows.Forms.NativeWindow.AssignHandle(IntPtr handle, Boolean
assignUniqueID) at
System.Windows.Forms.NativeWindow.AssignHandle(I...'

But if I build (for the first time) the entire solution, I can drag the
control without any error. Then if I drag a second one, I get the
exception again. If I rebuild it will be fine, and so on... Sometimes I
can drag 2 controls with no error and will need a recompile for the 3rd
one.

I have no idea where to search and especially how to debug that with C#
express.

Any idea ?

Thank you for your help

.



Relevant Pages

  • Re: Drag a file(path) from an Access Form into another app?
    ... Only thing is I'm not using a .Listview control. ... picturebox, image, and textbox, all support OLE drag and drop. ... Private Sub ListView0_MouseDown(ByVal Button As Integer, ...
    (microsoft.public.access.formscoding)
  • Re: Drag a file(path) from an Access Form into another app?
    ... Private Sub ListView0_MouseDown(ByVal Button As Integer, ... I've simulated drag and drop in Access before, ... goal here is to actually use Windows drag and drop, ... custom control is the answer. ...
    (microsoft.public.access.formscoding)
  • TreeView Mouse event behaviour puzzles
    ... I am looking to implement drag & drop in a TreeView control. ... I changed to the MouseDown/MouseMove/MouseUp approach the MouseDown/MouseUp ... ...Numerous MouseMove events occur in succession here ...
    (microsoft.public.dotnet.general)
  • Re: What do I call what I want to do?
    ... Inherit the class from System.Windows.Forms.CommonDialog. ... and you can drag it onto your project (it ... it doesn't work - it looks for a dll and can't find it. ... A control is a class. ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Cant understand this exception at design time
    ... your control is trying to evaluate a property or an object which is null. ... > System.Windows.Forms.NativeWindow.AssignHandle(IntPtr handle, Boolean ... > firstChild) at ... > But if I build the entire solution, I can drag the ...
    (microsoft.public.dotnet.framework.windowsforms.designtime)