Reference to a non-shared member requires an object reference

Sean Kelly

Member
Joined
Dec 28, 2005
Messages
12
Programming Experience
10+
I am getting the following error message when i try to build my project now, can't understand what i have done wrong here, any ideas?

Reference to a non-shared member requires an object reference

It has a problem with the system part of my designer form I have included a sample with errors below.

VB.NET:
[SIZE=2]<[/SIZE][SIZE=2][COLOR=#0000ff]Global[/COLOR][/SIZE][SIZE=2].Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
[/SIZE][SIZE=2][COLOR=#0000ff]Partial[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE][SIZE=2] MainScreen
[/SIZE][SIZE=2][COLOR=#0000ff]Inherits[/COLOR][/SIZE][SIZE=2] System.Windows.Forms.Form
[/SIZE][SIZE=2][COLOR=#008000]'Form overrides dispose to clean up the component list.
[/COLOR][/SIZE][SIZE=2]<System.Diagnostics.DebuggerNonUserCode()> _
[/SIZE][SIZE=2][COLOR=#0000ff]Protected[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Overrides[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Dispose([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] disposing [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Boolean[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] disposing [/SIZE][SIZE=2][COLOR=#0000ff]AndAlso[/COLOR][/SIZE][SIZE=2] components [/SIZE][SIZE=2][COLOR=#0000ff]IsNot[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]components.Dispose()
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]MyBase[/COLOR][/SIZE][SIZE=2].Dispose(disposing)
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][SIZE=2][COLOR=#008000]'Required by the Windows Form Designer
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2] components [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.ComponentModel.IContainer
[/SIZE][SIZE=2][COLOR=#008000]'NOTE: The following procedure is required by the Windows Form Designer
[/COLOR][/SIZE][SIZE=2][COLOR=#008000]'It can be modified using the Windows Form Designer. 
[/COLOR][/SIZE][SIZE=2][COLOR=#008000]'Do not modify it using the code editor.
[/COLOR][/SIZE][SIZE=2]<System.Diagnostics.DebuggerStepThrough()> _
[/SIZE]


the word system is underlined and highlighted as the error on the line
<System.Diagnostics.DebuggerNonUserCode()>

Thanks for any help

 
It is strange that you are getting that error with the main namespace ('System'). It could be that you have somehow confused the IDE. I know it sounds stange but I have had similar problems. To fix it I had to create a new form or class and copy the code and controls from the existing one to the new one. Hope that helps :).
 
Back
Top