質問

I've just added CsvHelper to my project via Nuget. Looking on the CsvHelper wiki page here: https://github.com/JoshClose/CsvHelper/wiki/Basics, it says CsvHelper exposes a WriteRecords method.

Where did it go? I can't find it in the assembly.

Where did WriteRecords Method go?

役に立ちましたか?

解決

The reason this happened is more than likely NuGet was selecting the wrong version of CsvHelper. Like others have commented, your project probably has the .NET 2.0 build of CsvHelper, even though your project is a 4.5 project.

There was/is (seems to come back) a bug in NuGet where it will select the full .NET version of a library instead of the client profile version, even if the client profile version is a higher version, or matching version in your case.

In CsvHelper, the .NET 2.0 build is a full version because there is no client profile available. All the other versions are client profile builds.

The solution here is to upgrade your NuGet and hope they have it fixed. If NuGet chooses the wrong one, you can manually remove the reference, and choose the correct one in the correct folder of the NuGet packages instead.

A lot of people have reported this issue, unfortunately there is nothing I can do to change it; as far as I understand. I filed a bug with NuGet and it was fixed, but some people are reporting that it happens on later versions of NuGet; though I haven't experienced this my self.

This is the fixed NuGet bug. http://nuget.codeplex.com/workitem/2502

他のヒント

Check the .NET target runtime. ICSVWriter does expose WriteRecords but only if it does not target .NET 2.0

If you look at the source of CsvWriter, you see that there is a WriteRecords method. What version of CsvHelper do you have installed?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top