ExportToCsv Library Not Working in .NET 8 (Could not load type 'System.Web.HttpContext' from assembly 'System.Web' Exception)

Aman Agrahari 60 Reputation points
2025-06-10T10:21:04.6+00:00

Hi,

I'm currently migrating a WinForms application from .NET Framework 4.7.2 to .NET 8, and I'm getting an exception with the ExportToCsv library, we were using it to export tabular data of Order Book, Trade Book to CSV files.

In .NET Framework, we used the following code:
ExportToCSV.Export objExport = new ExportToCSV.Export("WinForms");
objExport.DetailsForExportWOHeaders(dtDataExport, ExportToCSV.Export.ExportFormat.CSV, olOrderLog);

However, after migrating to .NET 8, I’m getting the following exception:
image (22)

It seems like the ExportToCsv library references System.Web internally, which is not supported in .NET 8.
image (23)

My Questions:

  1. Is there a .NET 8-compatible version of ExportToCSV?
  2. Is there any temporary solution for using ExportToCSV in .net 8?
  3. If not, what are the recommended alternatives for exporting tabular data of farpoint spreadsheet to CSV in a WinForms app using .NET 8?
  4. Are there any open-source libraries or best practices for handling CSV export in modern .NET?

Any guidance or suggestions would be greatly appreciated!

Thanks in advance.

Community Center Not monitored
0 comments No comments
{count} votes

Accepted answer
  1. Pradeep M 9,765 Reputation points Microsoft External Staff Volunteer Moderator
    2025-06-10T14:10:42.6266667+00:00

    Hi Aman Agrahari

    Thank you for reaching out to Microsoft Q & A forum.     

    The issue you're facing occurs because the ExportToCSV library uses System.Web.HttpContext, which is no longer supported in .NET 8. This is a common limitation when migrating from .NET Framework to modern .NET versions. 

    To address your questions: 

    1.There isn’t a .NET 8-compatible version of ExportToCSV. 

    2.As a workaround, the library would need to be modified to remove HttpContext usage.  

    3.For a long-term solution, I recommend using alternatives like CsvHelper or native .NET methods (StringBuilder with File.WriteAllText) to handle CSV export in WinForms. 

    These options are reliable, well-supported, and align with best practices in .NET 8. 

    If you have found the answer provided to be helpful, please click on the "Accept answer/Upvote" button so that it is useful for other members in the Microsoft Q&A community.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.