Skip to content

[BUG] - IAsyncEnumerable not correctly detected in net472 #974

Closed

Description

@JustinGrote

Continuation of #953 CC @michelebastione

When implementing using a channel in net472, MiniExcel does not detect the IAsyncEnumerable correctly and throws a notImplementException when it goes to GetWriteAdapter instead of GetWriteAsyncAdapter.

If you retarget the below code to net10.0, it works.

Program.cs

using MiniExcelLibs;
static async IAsyncEnumerable<Row> GetRowsAsync()
{
	for (var i = 1; i <= 10; i++)
	{
		await Task.Delay(25);
		yield return new Row(i, $"Item {i}");
	}
}

var outputPath = Path.Combine(Environment.CurrentDirectory, "output.xlsx");

await MiniExcel.SaveAsAsync(outputPath, GetRowsAsync());



public record Row(int Id, string Name);

CSProj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net472</TargetFramework>
    <LangVersion>latest</LangVersion>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="MiniExcel" Version="1.44.1" />
    <PackageReference Include="PolySharp" Version="1.16.0" />
    <PackageReference Include="Microsoft.BCL.AsyncInterfaces" Version="10.0.9" />
    <PackageReference Include="System.Threading.Channels" Version="10.0.9" />
  </ItemGroup>

</Project>

Run Result

Unhandled Exception: System.NotImplementedException: The method or operation is not implemented.
   at MiniExcelLibs.WriteAdapter.MiniExcelWriteAdapterFactory.GetWriteAdapter(Object values, Configuration configuration)
   at MiniExcelLibs.OpenXml.ExcelOpenXmlSheetWriter.<WriteValuesAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MiniExcelLibs.OpenXml.ExcelOpenXmlSheetWriter.<CreateSheetXmlAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at MiniExcelLibs.OpenXml.ExcelOpenXmlSheetWriter.<SaveAsAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MiniExcelLibs.MiniExcel.<SaveAsAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MiniExcelLibs.MiniExcel.<SaveAsAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Program.<<Main>$>d__0.MoveNext() in C:\Users\justi\Projects\Sandbox\MiniExcelTest\Program.cs:line 5
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Program.<Main>(String[] args)

Likely Problem

var writeAdapterType = typeof(AsyncEnumerableWriteAdapter<>).MakeGenericType(genericArgument!);
writeAdapter = Activator.CreateInstance(writeAdapterType, values, configuration) as IMiniExcelWriteAdapterAsync;
return true;

This code returns false for the IAsyncEnumerable, and is not detecting it correctly.

Activity

  1. JustinGrote commented on Jun 16, 2026

    @JustinGrote
    Author

    I tested 2.0.0-preview.4 and it seems to work there, but I'll leave this open for a decision to either backport the fix to 1.x or just close the issue and tell people to use 2.0

  2. michelebastione commented on Jun 17, 2026

    @michelebastione
    Collaborator

    Thank you for reporting the issue, we'll try to address it in the next release. This is actually a dependency resolution issue specifically affecting .NET Framework that wasn't apparent before. In the meantime you should be able to circumvent the issue by removing the current reference to the MiniExcel package in your project and adding the following snippet:

    <ItemGroup> 
      <PackageReference Include="MiniExcel" Version="1.44.1" ExcludeAssets="compile" GeneratePathProperty="true" /> 
      <Reference Include="MiniExcel"> 
        <HintPath>$(PkgMiniExcel)\lib\netstandard2.0\MiniExcel.dll</HintPath> 
      </Reference> 
    </ItemGroup>
  3. linked a pull request that will close this issueAdded net461 compilation target #978on Jun 25, 2026
  4. JustinGrote commented on Jun 26, 2026

    @JustinGrote
    Author

    Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions