Ambiguous link in Stream

This is the webservice method, I have

 LoadImageFromDB(int ID, ref Stream streamReturnVal)

I have it at the top of the section using Stream = System.IO.MemoryStream;

Whenever I use this method (update web link) from a web application, I get this error

 'Stream' is an ambiguous reference between 'System.IO.Stream' and 'WebReference.Stream'

Any thoughts?

In webservice class

using Stream = System.IO.MemoryStream;
LoadImageFromDB(int ID, ref Stream streamReturnVal);

On the web page where the web service is used above:

Using WebReference

Stream streamReturnVal = null;
streamReturnVal = new MemoryStream();

WebserviceInstanceName.LoadImageFromDB(100,streamReturnVal );

PS: stream - from System.IO.Stream

+3
source share
3 answers

So, this is because you have two namespaces that contain types with the same name within the same code fragment.

So this section

using Stream = System.IO.MemoryStream;
LoadImageFromDB(int ID, ref Stream streamReturnVal);

must explicitly determine which type Streamis passed.

It should probably look something like this.

using Stream = System.IO.MemoryStream;
LoadImageFromDB(int ID, ref System.IO.Stream streamReturnVal);
+2
source

Try moving using Stream = System.IO.MemoryStreamwithin your namespace declaration.

0
source

Do you have a WebReference? This can create a problem.

0
source

Source: https://habr.com/ru/post/1784197/


All Articles