R – Type conflicts with ITSELF just because it’s included as a return type of a web method in an ASP.NET web service

asp.netcompiler-errorsweb services

I have an irritating problem, I'm creating an asp.net web service; this service should expose the functionality of an existing library, the service allows users to Upload files to our server by invoking the UploadFile method on the service. Here's the signature of the UploadFile method

public bool UploadFile(string bucketName, string desiredFileName, System.IO.Stream fileData)

Now, when I try to invoke this method and pass it a System.IO.Stream object referring to the file to be uploaded, I get a compile time error, indicating the the passed in type (System.IO.Stream) is not the expected type (Mynamespace.ServiceReference.Stream). I tried to explicitly cast my stream to the type (Mynamespace.ServiceReference.Stream) but the compiler wouldn't let me do it either, though they are of the same type! weired!

Best Answer

The problem is in order to generate the WSDL the Stream will attempt to be serialized which it can't do.

Your original idea of a byte[] is the correct way to do it.

You do not need to bother with Base64 conversion because the ASP.NET runtime will do this for you already.

Related Topic