An unhandled exception

  • Thread starter Thread starter glendower
  • Start date Start date
G

glendower

Guest
I keep getting an error when ever I run a project in vb.net.

If the project has been created on my PC I get the error, however if the code was generated on another PC - no problems occur.

Even a simple project with a blank form fails with the same error

An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll

Additional information: Object reference not set to an instance of an object.

Execution fails at the 1st line

Visual Basic:
Public Class Form1  'fails here with line in green
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.TextBox1 = New System.Windows.Forms.TextBox()
        Me.SuspendLayout()
        '
        'TextBox1
        '
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.TabIndex = 0
        Me.TextBox1.Text = "TextBox1"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.TextBox1})
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region

End Class
I am getting desperate, all that is left to me is to reinstall Win2000
:mad: :mad: fails here with line in green
 
Last edited by a moderator:
I am missing where the error occurs, do you happen to have any pannels or boxes on your form ?
 
yes, the error is :


An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll

Additional information: Object reference not set to an instance of an object.


which appears in a box and the line

Public Class Form1

is highlighted in green
 
Sorry - misread your reply

No there is nothing on the form, that is the problem, I get this error on every project I create, no matter how simple I make it. The example I originally posted is a blank for with no controls.
 
The only way i can think that you are pulling up that error is if the form is actually anmed something else. There could be a problem in your dll and if you AiM me ill try to send you mine. That error happens when you make a refrence to a class (form) that hasnt been initilized or has been set to nothing...

I jsut started up a new project, and i noticed that you are missing some drawing code, not that i am sure it would help but...


Code:
        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(32, 72)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(240, 20)
        Me.TextBox1.TabIndex = 0
        Me.TextBox1.Text = "TextBox1"
 
Thanks for all the help.

I have now solved the problem but I think the solution may itself need some investigation.

I resolved the problem by simply logging on (win2000) as a differnet user.

All the projects that previously failed with the above problems ran with no errors at all.

If anybody can explain this to me it would be very much appreciated.
 
Could be the install... when VB.Net installs it installs permissions to only the person logged in... that means only that person can use thouse files if you have security up... most of the time this is evidant in an enviroment that the Admin installed iit and and User tries using the files
 
I got the same problem.
When I created the exe file, the program ran fine in the machine which created the exe file. However, when I ran the exe in another machine with .net framework installed, the same exception threw when the application started. I am using vb.net standard boxset. I have no impression that it mentioned about permession when I installed it.
Can anyone suggest to me how to solve the problem?

Thanks
 
Maybe your program is trying to load something from a resource stream embedded in a satellite assembly you forgot to distribute along with the main EXE file?
 
Back
Top