Visual Studio 2012を使用していて、WindowsPhone7.1アプリケーション開発で遊んでいます。これは新しく作成されたプロジェクトです。
このコードを使用すると、なぜこのエラーが発生するのですか?
The name 'WebRequestMethods' does not exist in the current context
コード:
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;
...
public MainPage() {
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.google.com");
request.Method = WebRequestMethods.Http.Post;
}
...
WebRequestMethodsがSystem.Netの一部であることを認識できないようです。System.Net.WebRequestMethods.Http.Postを指定した場合も失敗します。