C# WCF服务参考呼叫返回“;远程服务器返回错误:NotFound;
我在为这件事发愁 我有一个WCF接口,用于在web服务器上调用。所有其他函数都工作正常,但我添加的新函数导致在End函数中的Reference.cs自动生成文件中出现“远程服务器返回错误:NotFound.” 我知道服务器被找到了,我的调试器在服务端中断,它显然被调用并返回正确的类型 还有什么会导致这种误导性错误C# WCF服务参考呼叫返回“;远程服务器返回错误:NotFound;,c#,wcf,silverlight,web-services,C#,Wcf,Silverlight,Web Services,我在为这件事发愁 我有一个WCF接口,用于在web服务器上调用。所有其他函数都工作正常,但我添加的新函数导致在End函数中的Reference.cs自动生成文件中出现“远程服务器返回错误:NotFound.” 我知道服务器被找到了,我的调试器在服务端中断,它显然被调用并返回正确的类型 还有什么会导致这种误导性错误 [ServiceContract] public interface IDatabaseQueries { ... [OperationContract(AsyncPatter
[ServiceContract]
public interface IDatabaseQueries
{
...
[OperationContract(AsyncPattern = true)]
IAsyncResult BeginGetItemFromId(int itemID, AsyncCallback callback, Object state);
RmaItem EndGetItemFromId(IAsyncResult result);
...
}
[DataContract]
[KnownType(typeof(ItemType))]
[KnownType(typeof(Location))]
[KnownType(typeof(DateTime))]
public class RmaItem
{
...
}
[SilverlightFaultBehavior]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[KnownType(typeof(RmaItem))]
[KnownType(typeof(RmaReport))]
public class DatabaseService : IDatabaseQueries
{
...
public IAsyncResult BeginGetItemFromId(int itemID, AsyncCallback callback, Object state)
{
return new DatabaseResponse(itemID);
}
public RmaItem EndGetItemFromId(IAsyncResult result)
{
return GetRmaItemById((int)(result as DatabaseResponse).GetData);
}
...
}
在“Reference.cs”中崩溃:
编辑:
当我说所有其他函数时,我的意思是其他函数都是相同的IDatabaseQueries接口
编辑2::
原来问题是使用枚举作为字段(ItemType)。如上所示,我将ItemType作为已知类型。我在那种类型上缺少特殊条件吗?这是减速
[DataContract]
public enum ItemType
{
LOCATION, PART, ASSEMBLY
}
Silverlight无法理解所有错误。问题不在于服务器返回“未找到”,而是silverlight试图查找wcf返回的错误,但它找不到 您可以使用类似查找更多信息的方法或使用类似的数据包嗅探器。已解决 我缺少ItemType枚举中每个值的EnumMember
[DataContract]
public enum ItemType
{
[EnumMember]
LOCATION,
[EnumMember]
PART,
[EnumMember]
ASSEMBLY
}
感谢您的回复McAden我觉得这是因为我要返回类型项目。它是第一个返回此类型的函数,也是唯一有问题的函数。我错过了什么??
[DataContract]
public enum ItemType
{
[EnumMember]
LOCATION,
[EnumMember]
PART,
[EnumMember]
ASSEMBLY
}