3 Replies - 1904 Views - Last Post: 18 October 2009 - 07:03 PM Rate Topic: -----

#1 zedth2  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 121
  • Joined: 14-September 09

cant figure out error

Posted 18 October 2009 - 04:49 PM

I'n writing a program in visual studio 2008. I'm just going along and I get an error preventing me from testing the program.

<Global.System.Diagnostics.DebuggerStepThroughAttribute()>  _
		Protected Overrides Sub OnCreateMainForm()
			[u]Me.MainForm = Global.offDB.frmoffDB[/u]
		End Sub



between the u and /u(something in the post isnt working right) is where it points me to then the message box pops up saying

An unhandled exception of type 'System.InvalidOperationException' occurred in offDB.exe

Additional information: An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object.

please help, i don't understand whats going and I'd like to continue programing this.

This post has been edited by zedth2: 18 October 2009 - 04:52 PM


Is This A Good Question/Topic? 0
  • +

Replies To: cant figure out error

#2 mark.bottomley  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 176
  • View blog
  • Posts: 990
  • Joined: 22-April 09

Re: cant figure out error

Posted 18 October 2009 - 06:27 PM

There are several possible causes - not enough code to get the full context.
1) You are trying to set an object attribute "MainForm" before the object is finished being created. Try placing the code in the MainForm onload method.
2) You are creating the MainForm with OnCreateMainForm which I assume creates the MainForm form - It would not have a MainForm attribute to fill in - it is the MainForm.
3) Global.offDB.frmoffDB may not exist at this point - again insufficient code to determine the real cause.
Was This Post Helpful? 0
  • +
  • -

#3 zedth2  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 121
  • Joined: 14-September 09

Re: cant figure out error

Posted 18 October 2009 - 06:36 PM

Well that code isn't my code it's microsofts. But I seem to have figured it out,

Dim columncounts As Integer = dgvdataset.ColumnCount()



apparently this code is some how interfering with that piece. I commented this line out and all of a sudden it worked. I don't understand why this is the case. Got any ideas on why this is?
Was This Post Helpful? 0
  • +
  • -

#4 zedth2  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 121
  • Joined: 14-September 09

Re: cant figure out error

Posted 18 October 2009 - 07:03 PM

Okay well that line of code was being globally active. I tried it as a private variable and it works fine now. Though still don't understand why it doesn't work globally.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1