JoshClose / CsvHelper

Library to help reading and writing CSV files
http://joshclose.github.io/CsvHelper/
Other
4.76k stars 1.07k forks source link

Could not load type 'AppendInterpolatedStringHandler' from assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral #1995

Open bbsimonbb opened 2 years ago

bbsimonbb commented 2 years ago

Whatever I try to do with CsvHelper, I get this exception the first time I try to read anything. My project targets net6.0. An example among many I've tried is...

            using (var dataCsvFileReader = new StreamReader(model.AGrid.OpenReadStream()))
            using (CsvReader dataCsvReader = new CsvReader(dataCsvFileReader, CultureInfo.InvariantCulture))
            {
                while (dataCsvReader.Read())
                {
                    var dataRecord = Enumerable.ToList(dataCsvReader.GetRecord<dynamic>());
                }
            }

Stack trace...

System.TypeLoadException HResult=0x80131522 Message=Could not load type 'AppendInterpolatedStringHandler' from assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Source=CsvHelper StackTrace: at CsvHelper.CsvHelperException.AddDetails(String message, CsvContext context) at CsvHelper.CsvHelperException..ctor(CsvContext context, String message) at CsvHelper.ReaderException..ctor(CsvContext context, String message) at CsvHelper.CsvReader.ParseNamedIndexes() at CsvHelper.CsvReader.ReadHeader() at ConfigStore.Controllers.PriceGrids.PriceGridsController.UploadGrid(String gridName, UploadModel model) in C:\Users\sboddy\source\repos\ConfigStore\ConfigStore\Controllers\PriceGrids\PriceGridsController.cs:line 50 at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync() at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()

JoshClose commented 2 years ago

What version of CsvHelper is referenced? There is a net6.0 version that it should be pointing to.