vb.net - The form referred to itself during construction from a default instance, which led to infinite recursion -
i trying create simple client (initiator) using quickfix graphical user interface. i'm using visual studio 2012 , programming in vb.net.
here problem : when launch app, have error : "an unhandled exception of type 'system.invalidoperationexception' occurred in windowsapplication1.exe
additional information: error occurred creating form. see exception.innerexception details. error is: form referred during construction default instance, led infinite recursion. within form's constructor refer form using 'me.'"
i have 2 files in project client gui.vb (http://pastebin.com/virgvnys) , myquickfixapp.vb (http://pastebin.com/tq1gxnsx). second 1 contains class integrates iapplication, subs.
the error happens when executes line : "dim initiator new socketinitiator(myapp, storefactory, settings, logfactory)" client gui.vb software highlights line file application.designer.vb :
protected overrides sub oncreatemainform() me.mainform = global.windowsapplication1.clientgui end sub
can me , tell me wrong ?
thank !
when dealing winforms, best proceeding avoid problems initialise (except simple variable assignation, example: dim filename string = "initiator.cfg"
fine) after gui has been constructed/loaded (on _load
method). reason why getting error because of referring main form (me.mainform =
) before has been created.
move dim initiator new socketinitiator(myapp, storefactory, settings, logfactory)
clientgui_load
(the load event
method of main form) , error disappear.
note: if want access initiator
"anywhere", should keep global declaration move assignation load event, is:
dim initiator socketinitiator 'at class level, outside sub/function (as previously)
and
initiator = new socketinitiator(myapp, storefactory, settings, logfactory) 'inside clientgui_load method.
Comments
Post a Comment