Any call for GetRecords giving no records with an error message. #1253
Replies: 13 comments
-
For sure problem lay in CsvReader which is simply empty and not initialized with data from stream reader. |
Beta Was this translation helpful? Give feedback.
-
Are you able to supply sample code that reproduces the issue? |
Beta Was this translation helpful? Give feedback.
-
I am seeing exactly the same issue. The project is .Net Core 2.2
The csv file has two cols Id and Word. I have tried using a class which has Id and Word as public properties but I am still seeing the same issue. Nothing fancy about it just using this code to test the library. |
Beta Was this translation helpful? Give feedback.
-
@MunkeeJuice Can you create sample code or a project, including the data, that reproduces this? |
Beta Was this translation helpful? Give feedback.
-
Sure can, do you just want me to add a sample to github and link you to the repo? Wont be able to do this until tomorrow i'm afraid, but i will do it first thing in the morning when i get to the office. |
Beta Was this translation helpful? Give feedback.
-
I have have made a test app at home but this was built under VS 2017 (getting a totally different error on that one) not 2019 like the one at work where i am seeing the above issue. I will create a test project in 2019 in the morning and link you to the repo once it's done. |
Beta Was this translation helpful? Give feedback.
-
Ok i rebuilt the project that i did at home in VS 2017 at work this morning in VS 2019 and am now getting this error Evaluation of method System.Linq.SystemCore_EnumerableDebugView`1[CsvHelper_Test.Test].get_Items() calls into native method Interop+Kernel32.ReadFile(System.Runtime.InteropServices.SafeHandle, byte*, int, int&, System.IntPtr). Evaluation of native methods The test project can be found here https://github.com/MunkeeJuice/CsvHelper_Test |
Beta Was this translation helpful? Give feedback.
-
I had this exact issue and was able to find a solution: First I had to turn on ProjectName > Properties > Debug > Enable native code debugging. Don't know why this was off by default, but it was. Then a more reasonable error message popup showed me the MissingFieldException error, and it instructed me to "Ignore missing fields by settings MissingFieldFound to null. This was accomplished with: Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
I encountered this issue, and I was unable to get it to work calling GetRecords(). It works if i loop through the results using a read() and GetRecord() I made a netfiddle. |
Beta Was this translation helpful? Give feedback.
-
@abbottmw Your fiddle doesn't generate an error for me. public class Program
{
public static void Main()
{
string foo = @"1,one";
using (TextReader reader = new StringReader(foo))
using (var csv = new CsvReader(reader))
{
csv.Configuration.HasHeaderRecord = false;
//this works
var records = csv.GetRecords<Test>();
Console.WriteLine(JsonConvert.SerializeObject(records));
}
}
}
public class Test
{
[Index(0)]
public int Id { get; set; }
[Index(1)]
public string Name { get; set; }
} |
Beta Was this translation helpful? Give feedback.
-
Okay that worked for me thank you, but what still isnt working is I have a DataParser class i wrote that contains all the csvHelper calls and a Parse() method that returns the csv.GetRecords(), but I cannot do anything with it as it has an error. Probably user error. What am I doing wrong here? |
Beta Was this translation helpful? Give feedback.
-
return csv.GetRecords<T>().ToList();
|
Beta Was this translation helpful? Give feedback.
-
Worked for me. Thank you very much. :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In the case of that error, your library is for me totally useless. Do you have an idea of what is going on?
The exception occurs as a return error value of GetRecord function:
Evaluation of method System.Linq.SystemCore_EnumerableDebugView
1[<>f__AnonymousType0
2[System.Int64,System.String]].get_Items() calls into native method Microsoft.Win32.Win32Native.ReadFile(Microsoft.Win32.SafeHandles.SafeFileHandle, byte*, int, int&, System.IntPtr). Evaluation of native methods in this context is not supported.and the stack trace:
Beta Was this translation helpful? Give feedback.
All reactions