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