I have a warning that I can;t get rid of:

Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated.

I am pretty sure it is becasue I have not dimentioned the variable but how do you dimention an IO.memorystream.

Here is the code:

Photograph1.Image = Photograph1.Image.FromStream(New IO.MemoryStream(arr))

Any help would be greatfull. The programms runs and works, its just got those annoying warnings.

I know that to load an image from a file I do

Photograph1.Image = New Bitmap(filename)

I can't recommend what you should do without knowing what arr is or what it contains.

Sorry, didn't explain very well. arr is a binary data file stored in a database.

What is odd is that loading from a file (as your example) doesn't give the warning, but loading from io.memorystream does. Why?

Edited 3 Years Ago by UKnod

So if arr already contains binary data why do you need the IOStream? And if you do need the IOStream then try

    Photograph1.Image = New Bitmap(New IO.MemoryStream(arr))

It's not my area of expertise so I'm just throwing out suggestions and hoping that one sticks.

Edited 3 Years Ago by Reverend Jim

arr is a binary data file stored in a database

Assuming that this means that "arr" is a byte array that has been loaded from a database, then

change: Photograph1.Image = Photograph1.Image.FromStream(New IO.MemoryStream(arr))

to: Photograph1.Image = Image.FromStream(New IO.MemoryStream(arr))

FromStream is a shared method on the Image class. The IDE does not like you accessing a shared method/field/property on an instance eventhough as it works as you have found out. In this case, the instance is the Image property on Photograph (assuming Photograph is a PictureBox).

Thank you so much you guys, both options worked a treat so I went with TnTinMN just because it seemed the right way to go.

This question has already been answered. Start a new discussion instead.