Visual Studio 2005 - VB - System.Drawing - FromStream() method not available

I am trying to use the following line of code in Visual Studio 2005:
Imports System.IO
Imports System.Drawing

Sub Base64Convert(ByVal Base64MSG As String, ByRef ID As String, ByRef FName As String, ByRef LName As String)
    'Setup image and get data stream together
    Dim img As System.Drawing.Image
    Dim MS As System.IO.MemoryStream = New System.IO.MemoryStream

    Dim b64 As String = Base64MSG
    Dim b() As Byte

    'Converts the base64 encoded msg to image data
     b = Convert.FromBase64String(b64)
     MS = New System.IO.MemoryStream(b)

   'creates image
    img = System.Drawing.Image.FromStream(MS)

   'writes image for displaying
   img.Save(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) & "sig_" & ID & "_" & FName & "_" & LName & ".bmp", System.Drawing.Imaging.ImageFormat.Bmp)
   'cleaning up house
   End Sub

This line: img = System.Drawing.Image.FromStream(MS)
presents a syntax error saying 'FromStream is not a member of System.Drawing.Image'

When VS 2005 attempts to autocomplete as I type: System.Drawing.Image.
It only presents 3 choice, which are: Equals, FromHBitMap, and ReferenceEquals

Does anyone have any idea what is going on here?

Thanks much.
Who is Participating?
Do what microbolt said. Even if its there, load it again.

I use VS 2005. When I add System.Drawing as a reference it is Version  I mention the version number because you said,  "Auto Complete worked all the way  to System.Drawing.Image".  So there is a version of System Drawing already added as a reference.  Are you using the .Net CF. It does not support FromStream. but does support FromHBitMap.

Thats a new error for me, hanvn't seen that ever happen.  Could try to remove and rereference the System.Drawing Namespace.  Can remove the reference this way:

             Project -> {Project Name} Properties -> References Tab  

Then re-add the reference via:

             Project -> Add References

If it still does it try creating a new VB project and doing the same to see wether its a problem with Visual Studio or in the App that your writing.
jpbivonaAuthor Commented:
I do have System.Drawing Version Reference. I teied to remove and re-add, but didn't have an effect. You asked about .Net CF, is this the compact framework? I am using it I think, this code is for a mobile device application. Does this have any consequence?
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

jpbivonaAuthor Commented:
Or, how can I modify my code above to use the FromHBitMap Method?
Mike TomlinsonMiddle School Assistant TeacherCommented:
"...this code is for a mobile device application. Does this have any consequence?"

It has a HUGE impact.  The Compact Framework only has a SUBSET of the .Net Framework available to it.  

Look at the BOTTOM of these two MSDN pages in the "Version Information" sections.


    "Version Information
    .NET Framework
    Supported in: 2.0, 1.1, 1.0"


    "Version Information
    .NET Framework
    Supported in: 2.0, 1.1, 1.0
    .NET Compact Framework
    Supported in: 2.0"

The FromHBitMap() method has a ".NET Compact Framework" entry indicating that it is available in the CF.  The FromStream() method has no such entry...

Make sure to let people know in future questions if you are using the CF!    ;)
Think of CF as a stripped down version.

Check this link out about FromHBitMap 

I hope this helps. I've never used FromHBitMap myself.
jpbivonaAuthor Commented:
Ok, I will.

But what do I use to create a .bmp file from a hex text file in VB?

img = BitMap(MS)

BitMap(stream) is supported by CF
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.