bored...vb and C? RRS feed

  • Question

  • After taking a break from writing VB code, because with windows I have formatted my hard drive more times then my Visual Studio CD has been "misplaced" and I am not about to go purchase another visual studio, I decided to write a little java.  My code is so strange sometimes with declarations of variable type first but no sign of a semi-colon anywhere.  My comp throws a fit when I compile.  Anyway I digress, I happen upon this nifty express version and something inside start feeling warm and tingly as I start hoping and praying that I can start making VB applications again without reinstalling Visual Studio.  I have been writing almost non-stop in vb since I installed VBE :).   After sometime I remember how to throw an argument exception for my fun classes I make and wanting to know more about what an exception really is I copy the exception details to my clip board and paste it to note pad and this is what I get


    System.ArgumentException was unhandled

      Message="Value does not fall within the expected range."



           at x.Form1.Form1_Load(Object sender, EventArgs e) in G:\projectx\x\x\x\Form1.vb:line 21

           at System.EventHandler.Invoke(Object sender, EventArgs e)

           at System.Windows.Forms.Form.OnLoad(EventArgs e)

           at System.Windows.Forms.Form.OnCreateControl()

           at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)

           at System.Windows.Forms.Control.CreateControl()

           at System.Windows.Forms.Control.WmShowWindow(Message& m)

           at System.Windows.Forms.Control.WndProc(Message& m)

           at System.Windows.Forms.ScrollableControl.WndProc(Message& m)

           at System.Windows.Forms.ContainerControl.WndProc(Message& m)

           at System.Windows.Forms.Form.WmShowWindow(Message& m)

           at System.Windows.Forms.Form.WndProc(Message& m)

           at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

           at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

           at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

           at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)

           at System.Windows.Forms.Control.SetVisibleCore(Boolean value)

           at System.Windows.Forms.Form.SetVisibleCore(Boolean value)

           at System.Windows.Forms.Control.set_Visible(Boolean value)

           at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

           at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

           at System.Windows.Forms.Application.Run(ApplicationContext context)

           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()

           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()

           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)

           at x.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81

           at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)

           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

           at System.Threading.ThreadHelper.ThreadStart()


    Now I know my knowledge is limited but isn't x.My.MyApplication.Main(String[] Args) C code? and why is the variable type first?  Is there c in the background? When thrown in a class constructor it has x.{classname}..ctor is .ctor vb? or I am going crazy because I am trying to learn 2 different languages at once?

    Wednesday, July 26, 2006 4:47 PM


  • Remember, what you are running isn't VB (or C# or C for that matter), but IL. The compiler generates the IL from your source to come up with a more assembly like set of instructions which the JIT (Just In Time) compiler uses to create the actual machine code. The stack trace you are refering to simply uses the C style structures because the team that was responsible for doing that part and it was what they were most familiar with.

    As for ..ctor, that is the IL interpretation of Sub New() and is the class/object constructor. All classes have constructors even if you don't explicitly create one.

    I'm glad you have found the joy in VB again and have come back from the dark side ;-)

    Jim Wooley

    Wednesday, July 26, 2006 5:40 PM