Windows Develop Bookmark and Share   
 index > Windows Forms General > Displaying JPEG From Dime Attachment
 

Displaying JPEG From Dime Attachment

Hi

I am using Web Services Extension 1.0 to return JPEG in dime attachment and display it on windows forms. According to Microsoft documentation it should be quit easy:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wse/html/gxaconaddingattachmentstosoapmessageusingdime.asp

Here is a web service code :


[WebMethod]
public string DownloadImage(int imageID)
{
     try
          {
          clientsLLBL.DALScannedImages oScann = new clientsLLBL.DALScannedImages();
oScann.ImageID=imageID;
                // this saves image on the disc
 oScann.SelectOneImage();

               SoapContext myContext = HttpSoapContext.ResponseContext;

               DimeAttachment dAttachment = new DimeAttachment("image/jpeg",TypeFormatEnum.MediaType,"c:\\WS_log\\retrievedImage.jpg");

               myContext.Attachments.Add(dAttachment);

return "Succeded";
}
catch (Exception ex)
{
       throw ex;

                 }
}          
  


Here is win form code:


EFS_Register.downloadImage.downloadImage si = new EFS_Register.downloadImage.downloadImage();

int imageID = DataStorage.tempInteger;
string result = si.DownloadImage(imageID);

userPictureBox1.Image = new Bitmap(si.ResponseSoapContext.Attachments[0].Stream);



The error is: 
" A generic error occured in GDI+.System.Drawing at Sysytem.Drawing.Bitmap..ctor(Stream stream) ...."

I have tried saving attachment to the disk using Application.StartupPath as an argument to a Bitmap constuctor and then reading the file and displaying in picture box. It worked fine until updater component downloaded new version of the application.
For some reasion Application.StartupPath was set to the old version and that folder is deleted.

If I try to pass any other file path to the Bitmap constructor sach as: "c:\\image.jpeg" I get the following error:

"Invalid Parameter used.SystemDrawing at System.Drawing.Bitmap..ctor(String filename)"

Any help will be gratly appreciated.
MigrationUser 1  Wednesday, November 10, 2004 7:30 AM
The error was in webservice code. The old image file has to be removed before saving it with the file stream object.

These errors are difficult to trace as the exceptions thrown in Data Access Layer are not bubbled through the web service. I am trying to catch some of the errors by writing them into log files on the server.



MigrationUser 1  Thursday, November 11, 2004 4:23 AM

You can use google to search for other answers

Custom Search

More Threads

• How to choose the execution thread for a delegate?
• Bitmap Images
• i need help in graphics
• Cross-thread Form ownership issue
• Messenger login/logout?
• MonthCalendar.SelectionEnd different return results in XP and Vista
• .exe file keeps looping
• How to list environment variables?
• How could events from controls in a collection be trapped?
• Focus in textBox