I've seen several newsgroup topics everywhere concerning
this, as well as a couple of articles from the MSDN
website, but this error still baffles me.
It has to do with using the Image.FromStream(...) function
to load an image into a PictureBox control from a byte
array received from an SQL Server database. Here's a
snippet of what I've been trying to achieve:
----------------------------
Dim my_image() As Byte = CType(MyDataTable.Rows(0).Item
("DBImage"), Byte()) 'This is the picture returned back
from the database as array of values. Works fine.
Dim my_stream As New System.IO.MemoryStream
(my_image) 'This also works fine.
picPictureBox.Image = System.Drawing.Image.FromStream
(my_stream) 'This is the line of code that's driving me
CRAZY!!
----------------------------
When that line of code is executed, an unhandled exception
error pops up stating exactly the following:
"An unhandled exception of type 'System.ArgumentException'
occurred in system.drawing.dll
Additional information: Invalid parameter used"
What baffles me is why this error even occurs.
The "FromStream" function takes in a System.IO.Stream
parameter, which I'm giving it, and I've even seen posts
on newsgroups where people have tried the exact same code
and had no error at all, while others still get it.
I'm trying to get away from having to temporarily save the
database picture to the harddrive, and then loading it
using System.IO.FileStream (which, of course, works
without problems) Do I have a bug-ridden version of
System.Drawing, or am I cursed by some hidden coding
demon!?!! Any help at all with this matter would be
AWESOME!!