Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 流中的模糊引用_C# - Fatal编程技术网

C# 流中的模糊引用

C# 流中的模糊引用,c#,C#,这就是我使用的webservice方法 LoadImageFromDB(int ID, ref Stream streamReturnVal) 我使用Stream=System.IO.MemoryStream将其放在一节的顶部 每当我从web应用程序中使用此方法(更新web引用)时,就会出现此错误 'Stream' is an ambiguous reference between 'System.IO.Stream' and 'WebReference.Stream' 有什么想法吗 在

这就是我使用的webservice方法

 LoadImageFromDB(int ID, ref Stream streamReturnVal)
我使用Stream=System.IO.MemoryStream将其放在
一节的顶部

每当我从web应用程序中使用此方法(更新web引用)时,就会出现此错误

 'Stream' is an ambiguous reference between 'System.IO.Stream' and 'WebReference.Stream'
有什么想法吗

在webservice类中

using Stream = System.IO.MemoryStream;
LoadImageFromDB(int ID, ref Stream streamReturnVal);
在使用上述web服务的网页中:

使用网络参考

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

WebserviceInstanceName.LoadImageFromDB(100,streamReturnVal );

PS:Stream-来自System.IO.Stream

尝试使用Stream=System.IO移动
。MemoryStream
位于命名空间声明中。

是否使用WebReference?这可能会产生问题。

因此,如果在一段代码中有两个名称空间包含具有相同名称的类型,则会导致此问题

所以这部分

using Stream = System.IO.MemoryStream;
LoadImageFromDB(int ID, ref Stream streamReturnVal);
应该明确定义正在传递的
流的类型

它应该看起来像这样

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

我已经在我的Web服务中使用Stream=System.IO.MemoryStream了。你能发布源文件的相关部分吗?另外,我想澄清的是,我的意思是使用
语句将
从您通常放置的命名空间外部(或上方)移动到它内部(命名空间块内部)。@sharpeye500:如果您的别名造成歧义,您几乎没有选择-重命名别名或使用完全限定的类名解决歧义(包括名称空间)。请通过从顶部查看代码来帮助我理解。目前还不清楚LoadImageFromDB中必须使用什么流。如果MemoryStream为:using MStream=System.IO.MemoryStream;LoadImageFromDB(int ID,ref MStream streamReturnVal);否则:LoadImageFromDB(int ID,ref WebReference.stream streamReturnVal);Stream只不过是从字节读取图像并以内存流的形式发送回。从您对问题的更改来看,似乎您希望使用MemoryStream。在这种情况下,如果您将方法声明为LoadImageFromDB(int ID,ref System.IO.Stream streamReturnVal);您不需要别名“Stream”:使用Stream=System.IO.MemoryStream;如果别名概念对您来说是新概念,那么它只不过是不使用完全限定类名的快捷方式。使用Stream=System.IO.MemoryStream;没有多大帮助,除非您同时删除using System.IO。@msarchet-谢谢,我会在测试后告诉您。@Pauli,这就是我的意思,现在修复它我知道了,只是想指出它以便您可以更正:)@msarchet-谢谢,但我仍然收到“流中的模糊引用”错误,有什么想法吗?@Sharpeye500您也修复了WebReference中的一个吗