Strange Exceptions can be thrown -- new user help!

Strange Exceptions can be thrown -- new user help!

Old forum URL: forums.lhotka.net/forums/t/1050.aspx


figuerres posted on Monday, August 28, 2006

Hi, all perhaps this is covered somewhere - if not:

 

the WinPart UC and any control based on it need some other code added before use.

in learning the framework I new I needed to do stuff but was trying to get to a first visible thing on a form and....

so I make a UC based on WinPart,

toss on a BO with grid binding, ok looks good.

add that to a form and no errors.

compile no errors.

run:

Exception !

"Child" control is not a child control of .....

Ok look at some of the vaiables and the parent control's collection of child controls

HAS MY CONTROL!

so I am going "WTF?" spend some time trying things and finally see that unless I

took care of new,ToString and GetIDValue

then they and Equals and GetHashCode are hosed and the runtime gets all confused.

I gess when .Net adds a control it does a check to try and validate it with the hashcode or other functions and is unable to match the item to the list and blows chunks.

I know this now.... but for a bit I was lost as to why it was broke.

perhaps a note / warning that this will happen if you are in a rush might help save others some time when they first try and get started.

RockfordLhotka replied on Monday, August 28, 2006

It should be very clear that I made no real attempt to create a UI framework, or even meaningful approximation thereof, with the whole WinPart thing in Chapter 9. I took some basic concepts and put them together to show the beginnings of a path, but I surely didn't want to get sidetracked into building and describing a Windows Forms UI framework. That'd be a project/book all by itself!! Smile [:)]

figuerres replied on Monday, August 28, 2006

Yeah :-)  I just did not see the cliff at first :-)

you do have some good stuff to help get started ... even there where you stoped :-)

Just figured I'd share the adventure so that some other new  user might be warned about that.

cash_pat replied on Monday, August 28, 2006

I was getting this error once.

Your form or Control is missing the WinPart Code especially the GetIdValue


 Protected Overrides Function GetIdValue() As Object

        Return myBusinessObject

    End Function

ChristianPena replied on Monday, October 02, 2006

Please ignore.

Copyright (c) Marimer LLC