Null Ref in Sub New ()

bonedoc

Well-known member
Joined
May 4, 2006
Messages
112
Programming Experience
Beginner
I cannot figure out why I am getting a null ref in the this. The path to the image is correct. The value of the rectangle size is not missing. Any idease?

Sub New()

InitializeComponent()

Canvas = New Bitmap(Me.PictureBox1.Width, Me.PictureBox1.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)

Dim g As Graphics = Graphics.FromImage(canvas)

g.DrawImage(Image.FromFile("C:\windows\gone fishing.bmp"), New Rectangle(0, 0, canvas.Width, canvas.Height)) '''Errors here, Null Ref

g.Dispose()

End Sub
 
I don't get an null reference exception from this code, so it must be the image path.
 
perhaps windows isnt installed on drive c: or perhaps windows was installed to a different location than c:\windows
 
Back
Top