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

Posted on 2007-07-20
Last Modified: 2013-11-26
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.
Question by:jpbivona
    LVL 6

    Expert Comment

    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.
    LVL 1

    Accepted Solution

    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.


    Author Comment

    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?

    Author Comment

    Or, how can I modify my code above to use the FromHBitMap Method?
    LVL 85

    Assisted Solution

    by:Mike Tomlinson
    "...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!    ;)
    LVL 1

    Expert Comment

    Think of CF as a stripped down version.

    Check this link out about FromHBitMap  

    I hope this helps. I've never used FromHBitMap myself.

    Author Comment

    Ok, I will.

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

    Expert Comment


    img = BitMap(MS)

    BitMap(stream) is supported by CF

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
    This is an explanation of a simple data model to help parse a JSON feed
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now