我有一个简单的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.IO;
public partial class WebClient : PhoneApplicationPage
{
public WebClient()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
WebClient webclient = new WebClient();
现在,当我说 webClient. 时,我希望在 IntelliSense 下拉列表中看到 DownloadStringCompleted,但我没有看到。当我强制使用它时,它当然不会编译。有什么问题?
我正在测试 WebClient 以查看它是否在我的项目中有用,因为我受够了与 HttpWebRequest 关联的异步调用和多线程
请您参考如下方法:
出于某些奇怪的原因,您使用名称“WebClient”作为您的 PhoneApplicationPage 的类名。因此,当您使用此行时:-
WebClient webclient = new WebClient();
它试图创建您的页面的另一个实例,该实例当然没有 DownloadStringCompleted 或 System.Net< 中的 命名空间。WebClient 提供的任何其他内容
我强烈建议您为您的页面取一个不同的名称。如果您确实想将您的页面称为“WebClient”,那么“WebClientPage”怎么样?
