System.NullReferenceException when using ListObjectAdapter

Vojtěch Habrnal | UNIWISE 0 Reputation points
2024-08-22T08:41:13.0466667+00:00

Hello,

I am working with a legacy Excel Extension codebase where we are populating tables using Microsoft.Office.Tools.Excel. I am encountering a System.NullReferenceException in Microsoft.Office.Tools.Excel.ListObjectAdapter as shown in the picture below:

User's image

I have included relevant code below, but I have not been able to solve the issue. I have already checked to ensure that I am correctly logged into Visual Studio and Excel. I have also tried reading documentation without success.

private readonly ApplicationFactory factory;
private async Task ProcessSetting(WorkBookListOFvalues item, Stopwatch s, long time, StringBuilder print)
{
    ListObject tableLo = null;
    DataSet ds = null;
    DataTable data = null;

    try
    {
        try
        {
            globals.Dispatcher.Invoke(() =>
            {
                tableLo = factory.GetVstoObject(ExcelExtensions.GetListObject(TargettyFormLoadAndSave.Action.applicationSettings.Workbook, item.ListObject));
            });
        }
        catch (Exception e)
        {
			// Error handling
            return;
        }

Any help is appreciated.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,919 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,011 questions
0 comments No comments
{count} votes

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.