【发布时间】:2012-03-20 13:14:11
【问题描述】:
我正在尝试使用 Asp.NET WebAPI 模块,但出现了一个奇怪的错误。 当我尝试运行这个简单的程序时:
class Program
{
static void Main(string[] args)
{
System.Net.Http.HttpClient client = new HttpClient();
string data = client.GetStringAsync("http://www.kralizek.se/").Result;
Console.WriteLine(data);
Console.ReadLine();
}
}
我有这个错误。
System.MissingMethodException was unhandled
Message=Method not found: 'System.Threading.Tasks.Task`1<System.String> System.Net.Http.HttpClient.GetStringAsync(System.String)'.
Source=Connector.App
StackTrace:
at ConnectorApp.Program.Main(String[] args)
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
错误发生在 Visual Studio 和 LinqPad 中,但我的同事没有发生。
我认为可能与 .NET 4.5 开发预览存在某种冲突,因此我将其卸载但没有任何好处。
谢谢
【问题讨论】:
-
你引用的是 .net 4.5 吗?
-
不,我不是。但同一个 bin 文件夹在我的同事工作站上“按原样”运行
标签: asp.net httpclient asp.net-web-api