C# 未找到段';x';
我收到以下错误:未找到“GetTest”段的资源 代码如下:C# 未找到段';x';,c#,.net,wcf,C#,.net,Wcf,我收到以下错误:未找到“GetTest”段的资源 代码如下: [WebGet] public IQueryable<string> GetTest() { var tmp = new List<string>(); return tmp.AsQueryable(); } [WebGet] 公共IQueryable GetTest() { var tmp=新列表(); 返回tmp.AsQueryable();
[WebGet]
public IQueryable<string> GetTest()
{
var tmp = new List<string>();
return tmp.AsQueryable();
}
[WebGet]
公共IQueryable GetTest()
{
var tmp=新列表();
返回tmp.AsQueryable();
}
有什么问题吗?当查找不存在的主键时,会引发“找不到该段的资源”
用try-catch试试看
try
{
var tmp = new List<string>();
return tmp.AsQueryable();
}
catch( DataServiceQueryException ex )
{
return null;
}
试试看
{
var tmp=新列表();
返回tmp.AsQueryable();
}
捕获(DataServiceQueryException ex)
{
返回null;
}
我们可以看看您的客户端实现吗?你怎么称呼它?它是否可能返回null?