我正在为我的 .svc 网络服务创建调解器,但我无法返回。它一直给我一个错误
an object of type is convertable to "string" is required
我不知道我必须返回什么。这是我的代码。
var proxy = SomeProxy();
try
{
var contact = proxy.FindContactByLogin("0002221111", "test123", false);
if (contact.Result != SomeService.Results.Succeeded)
{
Assert.Fail(string.Join(Environment.NewLine, contact.Errors.ToString()));
return;
}
var result = proxy.GetAccountsListByContactID(contact.Value.ID);
if (result.Result == SomeService.Results.Succeeded)
{
Console.WriteLine(result.Value);
}
else
{
foreach (string error in result.Errors)
return error;
//Console.WriteLine(error);
}
}
finally
{
proxy.Close();
}
提前谢谢你。
最佳答案
您应该能够通过调试来准确确定代码出错的地方。
- 你的 try block 没有捕获。这就是您应该处理的地方。
- 该错误表明您正在尝试进行字符串转换。它可能是第 6 行的
contact.Errors.Tostring()
调用
关于C# 网络服务。需要可转换为 "string",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10319665/