Click here to Skip to main content
15,888,610 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionBinding Controls via Generic Method Pin
overtech0630-Apr-10 7:17
overtech0630-Apr-10 7:17 
AnswerRe: Binding Controls via Generic Method Pin
T M Gray30-Apr-10 7:57
T M Gray30-Apr-10 7:57 
GeneralRe: Binding Controls via Generic Method Pin
overtech0630-Apr-10 9:02
overtech0630-Apr-10 9:02 
AnswerRe: Binding Controls via Generic Method Pin
daveyerwin30-Apr-10 11:43
daveyerwin30-Apr-10 11:43 
GeneralRe: Binding Controls via Generic Method Pin
overtech0630-Apr-10 12:01
overtech0630-Apr-10 12:01 
GeneralRe: Binding Controls via Generic Method Pin
daveyerwin30-Apr-10 12:10
daveyerwin30-Apr-10 12:10 
GeneralRe: Binding Controls via Generic Method Pin
daveyerwin30-Apr-10 14:58
daveyerwin30-Apr-10 14:58 
AnswerReturn image from aspx page [modified] Pin
#realJSOP30-Apr-10 3:50
mve#realJSOP30-Apr-10 3:50 
I'm doing the following in a web page, and returning the results to a silverlight app:

Bitmap bmp          = new Bitmap(60, 30);

// code that renders objects on the bitmap

MemoryStream ms = new MemoryStream();
bmp.Save(ms,System.Drawing.Imaging.ImageFormat.Gif);

Byte[] buffer = new Byte[ms.Length];
ms.Read(buffer, 0, (int)(ms.Length));

Response.ContentType = "image/jpeg";
Response.BinaryWrite(buffer);

bmp.Dispose();
g.Dispose();


In the client, I'm doing this:

    string url = // create the desired url string
    WebClient client = new WebClient();
    client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted);
    client.OpenReadAsync(new Uri(url));

<br /><br />

void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
    BitmapImage bi = new BitmapImage();

    bi.SetSource(e.Result);  <---- crashes here with a "catastrophic failure"

    Image image = new Image();
    image.Source = bi;
    e.Result.Close();
    e.Result.Dispose();
    this.testImage.Child = image;
}


The e.Result property contains a 536-byte stream (which seems reasopnable given the size of the image), but it crashes in the indicated position. Does anyone know what I'm doing wrong?

Here's the exception I'm seeing:

{System.Exception: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))<br />
   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)<br />
   at MS.Internal.XcpImports.BitmapSource_SetSource(BitmapSource bitmapSource, CValue& byteStream)<br />
   at System.Windows.Media.Imaging.BitmapSource.SetSourceInternal(Stream streamSource)<br />
   at System.Windows.Media.Imaging.BitmapImage.SetSourceInternal(Stream streamSource)<br />
   at System.Windows.Media.Imaging.BitmapSource.SetSource(Stream streamSource)<br />
   at SLTestApp2.Home.client_OpenReadCompleted(Object sender, OpenReadCompletedEventArgs e)}

.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
modified on Friday, April 30, 2010 10:27 AM

GeneralRe: Return image from aspx page Pin
daveyerwin30-Apr-10 4:40
daveyerwin30-Apr-10 4:40 
GeneralRe: Return image from aspx page Pin
#realJSOP30-Apr-10 4:52
mve#realJSOP30-Apr-10 4:52 
GeneralRe: Return image from aspx page Pin
Abhishek Sur30-Apr-10 6:01
professionalAbhishek Sur30-Apr-10 6:01 
GeneralRe: Return image from aspx page Pin
#realJSOP30-Apr-10 7:38
mve#realJSOP30-Apr-10 7:38 
GeneralRe: Return image from aspx page Pin
Abhishek Sur30-Apr-10 23:45
professionalAbhishek Sur30-Apr-10 23:45 
GeneralRe: Return image from aspx page Pin
#realJSOP1-May-10 0:46
mve#realJSOP1-May-10 0:46 
GeneralRe: Return image from aspx page Pin
Rama Krishna Vavilala30-Apr-10 10:03
Rama Krishna Vavilala30-Apr-10 10:03 
QuestionScreen view fixed to the Last row/item of the Gridview Pin
Sandesh M Patil30-Apr-10 3:49
Sandesh M Patil30-Apr-10 3:49 
AnswerRe: Screen view fixed to the Last row/item of the Gridview Pin
daveyerwin30-Apr-10 7:01
daveyerwin30-Apr-10 7:01 
GeneralRe: Screen view fixed to the Last row/item of the Gridview Pin
daveyerwin30-Apr-10 7:18
daveyerwin30-Apr-10 7:18 
QuestionAdding scriptManager tag to Non ajax enabled web application Pin
salmonraju30-Apr-10 2:15
salmonraju30-Apr-10 2:15 
AnswerRe: Adding scriptManager tag to Non ajax enabled web application Pin
Sandeep Mewara30-Apr-10 2:45
mveSandeep Mewara30-Apr-10 2:45 
GeneralRe: Adding scriptManager tag to Non ajax enabled web application Pin
salmonraju30-Apr-10 3:12
salmonraju30-Apr-10 3:12 
QuestionHow to hide Querystring Parameters Pin
Sandesh M Patil30-Apr-10 1:21
Sandesh M Patil30-Apr-10 1:21 
AnswerRe: How to hide Querystring Parameters Pin
DaveAuld30-Apr-10 1:31
professionalDaveAuld30-Apr-10 1:31 
AnswerRe: How to hide Querystring Parameters Pin
Dinesh Mani30-Apr-10 1:35
Dinesh Mani30-Apr-10 1:35 
AnswerRe: How to hide Querystring Parameters Pin
Brij30-Apr-10 1:38
mentorBrij30-Apr-10 1:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.