Csvhelper: " No members are mapped for type", not on local Windows machine, but on CentOS machine

Created on 12 Feb 2019  路  3Comments  路  Source: JoshClose/CsvHelper

I am trying to parse a CSV file, getting this error. As a solution I also tried to register a class map but it doesn't help.

The strange thing is, it works on my local machine (Windows, .NET Core 2.2, ASP.NET Core 2.2.1), but it fails on my production machine (CentOS 7, .NET Core 2.2, ASP.NET Core 2.2.1) so it does not seem to be an issue with the configuration.

What is the possible causes of this exception, that are possibly environment dependent?

Stack Trace:
at CsvHelper.Expressions.ObjectRecordCreator.CreateCreateRecordDelegate(Type recordType)
at CsvHelper.Expressions.RecordCreator.GetCreateRecordDelegate(Type recordType)
at CsvHelper.Expressions.RecordCreator.CreateT
at CsvHelper.CsvReader.GetRecordsT+MoveNext()
...

Most helpful comment

I just ran into a similar problem and came across this issue looking for a solution. As I've now figured out what the cause was, I thought I would share it here.

The problem in my case was the delimiter. When you don't specify the delimiter explicitly, I suspect CsvHelper uses the default delimiter from your local culture settings, which in my case on Windows was a semi-colon. Therefore, if your file uses semi-colons, it will work fine on Windows. Then, when you move to a different OS (like in my case Linux in a Docker container), a different delimiter may apply (like a comma), and the exception you saw is raised.

So the safest solution is to specify the delimiter explicitly with Configuration.Delimiter.

All 3 comments

I just ran into a similar problem and came across this issue looking for a solution. As I've now figured out what the cause was, I thought I would share it here.

The problem in my case was the delimiter. When you don't specify the delimiter explicitly, I suspect CsvHelper uses the default delimiter from your local culture settings, which in my case on Windows was a semi-colon. Therefore, if your file uses semi-colons, it will work fine on Windows. Then, when you move to a different OS (like in my case Linux in a Docker container), a different delimiter may apply (like a comma), and the exception you saw is raised.

So the safest solution is to specify the delimiter explicitly with Configuration.Delimiter.

Oh I forgot to mention the solution when I solved it. Yes it was exactly that issue. Thanks for helping!

@rh78 In that case you should close the issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JoshClose picture JoshClose  路  4Comments

DmitryEfimenko picture DmitryEfimenko  路  3Comments

JoshClose picture JoshClose  路  5Comments

mabead picture mabead  路  3Comments

marcselman picture marcselman  路  4Comments