Search

Specified method is not supported. NotSupportedException crossed a native/managed boundary by JRisPicman

Active

7
0
Sign in
to vote
Type: Bug
ID: 637015
Opened: 1/19/2011 9:54:20 PM
Access Restriction: Public
1
Workaround(s)
4
User(s) can reproduce this bug
{"Specified method is not supported."}

Stack trace:
at System.Web.HttpResponseStream.get_Position()
at System.Drawing.UnsafeNativeMethods.ComStreamFromDataStream.Seek(Int64 offset, Int32 origin)

NotSupportedException crossed a native/managed boundary.

Code
Details (expand)

Visual Studio/Silverlight/Tooling version

Visual Studio 2010 SP1 Beta

What category (if any) best represents this feedback?

Reliability

Steps to reproduce

fullsizeImage = New Bitmap(DocName)

' create an image from the byte array
'ms = New MemoryStream(fullsizeImage)
'fullsizeImage = System.Drawing.Image.FromStream(ms)

Response.ContentType = "image/Jpg"
Dim ir As New ImageResize()

' Load your image and perform any resizing here
ir.File = fullsizeImage

If Request.QueryString("ImgWigth") = "" Then
If USE_SIZE_FOR_HEIGHT Then
ir.Height = THUMBNAIL_SIZE
Else
ir.Width = THUMBNAIL_SIZE
End If
Else
ir.Width = CDbl(Request.QueryString("ImgWigth"))
End If

'get the thumbnail
ir.GetThumbnail(ImageResize.ImageSize.Fullimage).Save(Response.OutputStream, ImageFormat.Jpeg)

The very last line is giving the error.

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

NotSupportedException crossed a native/managed boundary.

Expected results

No error.
File Attachments
File Name Submitted By Submitted On File Size  
ThumbNail.zip (restricted) 1/20/2011 -
BitmapBug.zip 6/22/2011 61 KB
Sign in to post a comment.
Posted by deeshubby on 6/5/2011 at 10:51 PM
I get this, too. Here's how to reproduce: Take any System.Drawing.Image byte stream, and try to serve it up as an ContentType="image/jpeg" via an .aspx page.

e.g.
ShowImage.aspx has the following minimal markup:
****************************
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="ShowImage.aspx.vb" Inherits="ShowImage" ContentType="image/jpeg" %>

And here's the class for the code-behind:
*****************************
Partial Class ShowImage
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim img As System.Drawing.Bitmap = Nothing

        Using img
            img = CType(Session("IMG"), System.Drawing.Bitmap)

            Response.Clear()
            Response.ContentType = "image/jpeg"
            img.Save(Response.OutputStream, Drawing.Imaging.ImageFormat.Jpeg) 'throws the error here
        End Using
    End Sub
End Class
Posted by Chris5gd on 4/12/2011 at 1:02 PM
I'm getting this exact message too, in code that's virtually identical to AndreZero's. The only difference is that I'm using a different overload of System.Drawing.Image.Save...

Public Sub Save(ByVal stream As System.IO.Stream, ByVal encoder As System.Drawing.Imaging.ImageCodecInfo, ByVal encoderParams As System.Drawing.Imaging.EncoderParameters).

This is in an ASP.NET application, and I'm using VS2010 on Win7 x86. It happens with both FF4 and IE8 as browser, and doesn't occur running outside Visual Studio. I have not yet applied SP1 to VS2010.
Posted by AndreZero on 2/17/2011 at 9:52 AM
Hi
I Have the same error. occurs in the save moment;

            System.Drawing.Bitmap img = new C2of5i(code, 1, 50, code.Length).ToBitmap();
            img.Save(context.Response.OutputStream, ImageFormat.Jpeg);
                                                                                                            

System.NotSupportedException crossed a native/managed boundary
Message=Specified method is not supported.
Source=System.Web
StackTrace:
     at System.Web.HttpResponseStream.get_Position()
     at System.Drawing.UnsafeNativeMethods.ComStreamFromDataStream.Seek(Int64 offset, Int32 origin)

Thanks in advance
Posted by JRisPicman on 1/20/2011 at 3:39 AM
Hi

I have uploaded the VB 2010 SP1 beta project and it is giveing the error, don't hesitate to as for something else.

Joop
Posted by Microsoft on 1/20/2011 at 1:34 AM
Thanks for reporting this issue. In order to fix the issue, we must first reproduce the issue in our labs. We are unable to reproduce the issue with the steps you provided.

Please give us a demo project to demonstrate this issue so that we can conduct further research.

It would be greatly appreciated if you could provide us with that information as quickly as possible. If we do not hear back from you within 5 days, we will close this issue.

Thanks again for your efforts and we look forward to hearing from you.

Microsoft Visual Studio Connect Support Team
Posted by Microsoft on 1/19/2011 at 9:58 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by andrej.lola on 6/22/2011 at 1:18 AM
Tools -> Otions -> Debugging -> General
Switch off "Break when exceptions cross AppDomain or managed/native boundaries (Managed only)"