Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1373
  • Last Modified:

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
   img.Dispose()
   MS.Close()
   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.
0
jpbivona
Asked:
jpbivona
2 Solutions
 
microboltCommented:
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.
0
 
billycotxCommented:
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 2.0.0.0.  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.
See http://msdn2.microsoft.com/en-us/library/system.drawing.image_methods.aspx

0
 
jpbivonaAuthor Commented:
I do have System.Drawing Version 2.0.0.0 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?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
jpbivonaAuthor Commented:
Or, how can I modify my code above to use the FromHBitMap Method?
0
 
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.

Image.FromStream()
http://msdn2.microsoft.com/en-us/library/93z9ee4x(vs.80).aspx

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

Image.FromHBitMap()
http://msdn2.microsoft.com/en-us/library/k061we7x(VS.80).aspx

    "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!    ;)
0
 
billycotxCommented:
Think of CF as a stripped down version.

Check this link out about FromHBitMap

http://www.velocityreviews.com/forums/t77332-dynamic-images.html 

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

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

img = BitMap(MS)

BitMap(stream) is supported by CF

http://msdn2.microsoft.com/en-us/library/z7ha67kw.aspx
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now