Home > front end >  COM is not supported: PlatformNotSupportedException in AWS Lambda .net 3.1
COM is not supported: PlatformNotSupportedException in AWS Lambda .net 3.1

Time:03-03

I am migrating a solution using AWS Lambda .NET 3.1. This solution was originally built in .NET 4.8 FRAMEWORK. When i build the solution with visual studio AWS SDK integration i have no issues, but when i test this in lambda console i get the following error message:

COM is not supported: PlatformNotSupportedException

at WeeklyDevReportGenerator.ParseDevopsCSVs.ParseCSV(String fileName)

    public void ParseCSV(string fileName)
    {
        xlApp = new Application();
        xlWorkbook = xlApp.Workbooks.Open(fileName);
        xlWorksheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkbook.Sheets[1];
        xlRange = (Microsoft.Office.Interop.Excel.Range)xlWorksheet.UsedRange;

        rowCount = xlRange.Rows.Count;
        colCount = xlRange.Columns.Count;

        Read();
        CleanUp();

        week  ;
    }

I am pretty lost this time, i am starting to think that i might neet to migrate the project to .NET 6.0 which is supported by aws.

Any other solution?

CodePudding user response:

You're going to need to rewrite your code that interacts with Excel workbooks.

Your code is (indirectly) using a technology called COM to communicate with a local instance of Excel. The error you're getting is saying that COM isn't supported on the Lambda runners, but an even more fundamental issue is that there is no Excel on the lambda runners.

The most straightforward way forward will be to replace your usage of Excel with a library that can read write Excel files. ClosedXML, EPPlus, Aspose.Cells and NPOI are all popular options.

  • Related