Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / December 2005

Tip: Looking for answers? Try searching our database.

Can't understand this exception at design time

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cadilhac@gmail.com - 23 Nov 2005 13:13 GMT
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
Montezuma - 28 Nov 2005 09:44 GMT
Hi,
your control is trying to evaluate a property or an object which is null.

I understand your disorientation, and honestly i don't get why those errors
that one gets in the design surface don't show the relative line directly.

You can find the line generating the error in the Error List, among the
Warnings. Well, weren't we talking about errors?...

By the way, according to my experience, the line reported is even the wrong
one, so you should check the behavior caused by the previous one.

Hope this helps.

Montezuma

> Hi,
>
[quoted text clipped - 38 lines]
>
> Thank you for your help
jokiz - 02 Dec 2005 10:13 GMT
you should debug the IDE instance you are dragging these controls with
another IDE...

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.