Click here to Skip to main content
15,886,808 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can anyone help me on this , I am getting an error like this :
System.InvalidOperationException: For request in operation UploadImage to be a stream the operation must have a single parameter whose type is Stream.

This is my code in servicecontract
C#
[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "{DataBaseName}/{TableName}/UploadImages?ID={ID}")]
bool UploadImage(string DataBaseName, string TableName, int ID, Stream ImageStream);
Posted
Updated 16-May-12 8:29am
v2
Comments
lisalis 16-May-12 15:29pm    
Hi Marcus thanks for your reply.

My interface part is

[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "{DataBaseName}/{TableName}/UploadImages?ID={ID}")]
bool UploadImage(string DataBaseName, string TableName, int ID, Stream ImageStream);



My Implement part is




public bool UploadImage(string ServiceName, string TableName, int ID, Stream ImageStream)


{
try

{

byte[] Picture= InsertImage(ImageStream);


my connectionstring and mysql command here(insert Upload image to the DB)
.....
}





public static byte[] GetImage(Stream ImageStream)

{
BinaryReader reader = new BinaryReader(ImageStream);

byte[] photo = reader.ReadBytes((int)ImageStream.Length);


reader.Close();

ImageStream.Close();


return photo;

}
manishkumar2080 29-Dec-12 0:00am    
I want whole coding via WCF , html5 with Jquery

1 solution

You need to make sure that the value you supply for ImageStream is of type Stream. The error message tells you exactly what is wrong. Show us the code where you make the call and we may be able to help further.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900