以下一小段代码在控制台应用程序中运行良好,但在 Silverlight 5 应用程序中(我需要它!)它通过抛出NotSupportedException失败:
var client = new ODataClient("http://MYSERVER:9000/OData_v4/ProductionDb/");
try
{
//This statement throws in Silverlight 5 but not in a .NET 4.5 Console application!!??
var Meter = await client
.For("MyEntityName")
.Top(1)
.FindEntryAsync();
foreach (var entry in Meter)
Debug.WriteLine(string.Format("{0}: {1}", entry.Key, entry.Value));
}
catch (NotSupportedException ex)
{
Debug.WriteLine(string.Format( "Exception {0}: {1} ", ex.GetType().ToString(), ex.Message ));
}
为什么它在 Silverlight 中不起作用?根据文档,它应该可以直接与 Silverlight 一起使用......?
我使用 NuGet 安装Simple.OData.Client版本。4.13.0(=最新稳定版)到我的 Visual Studio 2015 Silverlight 项目中。