6
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

DataTable に AsEnumerable の定義がありません

Posted at

.NET Framework 2.0 時代 (か、それより前) のプロジェクトを .NET 4 に書き換える作業で遭遇した問題。

2回目も思い出すのに時間を使ったのでメモしておく。 

症状

DataTable を IEnumerable<xxx> に読み替えようとして DataTable.AsEnumerable() したが、表題のエラーが表示されてビルドできない。

System.Linq を using しても症状が変わらない。

解決

プロジェクトの参照に、System.Data.DataExtensions を追加する。

.NET 4 をターゲットにしたプロジェクト (WinForms) を新規作成した場合、このアセンブリは最初から参照されていた。

確認した環境

  • Windows 10 Home
  • Visual Studio Community 2015
  • Visual Studio Community 2019
6
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?