Forum Moderators: open
I'm at my wit's end trying to figure out why these little snippets of code won't work:
Dim baseImg As bitmap = bitmap.fromfile(request.physicalApplicationPath & "\tempImgs\temp." & ext)
or
Dim baseImg As bitmap = new bitmap(request.physicalApplicationPath & "\tempImgs\temp." & ext)
or
Dim baseImg As new bitmap(request.physicalApplicationPath & "\tempImgs\temp." & ext)
I'm just trying to create a new Bitmap (a System.Drawing.Image would work, too) from a file. Each time I try, I get a NullReferenceException:
[NullReferenceException: Object reference not set to an instance of an object.]
System.Drawing.SafeNativeMethods.GdipCreateBitmapFromStream(IStream stream, IntPtr& bitmap) +0
System.Drawing.Bitmap..ctor(Stream stream) +117
ASP.throwaway2_aspx.Page_Load(Object obj, EventArgs E) in D:\htdocs\tech-secstate-wa-gov\generalwebtools\throwaway2.aspx:22
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +29
System.Web.UI.Page.ProcessRequestMain() +724
Things I've already checked:
- Using a Stream instead of a File as my argument to the constructor
- That the argument I'm giving it isn't null
- Running this from a VB class, instead of ASP, where it is now
- Giving this ASP app every conceivable permission on the server
Can anyone help?
Thanks a ton,
g.
There's nothing wrong with the filename I'm giving it. I save the file to that location using the same code on the line above this one, and the files show up fine. When I print it to the screen, it's exactly what I'd expect it to be. I get the same error trying to create Images and Bitmaps with their dimensions, instead of loading a file.
Thanks for trying,
g.