Excel-DNA / Excel-DNA/ExcelDna

ExcelHandle does not work with params object[]

Open
#852 1 comment 0 reactions 1 assignee Claimed by @Sergey-Vlasov View on GitHub
Dominant language
C#
Stars
1.5k
Forks
292
Avg merge
20d 12h
Merged PRs (30d)
1

Description

## Description

Using `params object[]` together with `[return: ExcelHandle]` causes Excel-DNA startup to fail.

This minimal example reproduces the issue:

```csharp
using ExcelDna.Integration;

public static class TestFunctions
{
[return: ExcelHandle]
[ExcelFunction]
public static object CreateHandle(
object value,
params object[] values
)
{
return new object();
}
}
```

Excel-DNA throws the following exception during initialization:

```text
Initialization [Error] Integration.DnaLibraryAutoOpen Error :
NotSupportedException -
A non-collectible assembly may not reference a collectible assembly.
```

Removing `params` fixes the issue:

```csharp
using ExcelDna.Integration;

public static class TestFunctions
{
[return: ExcelHandle]
[ExcelFunction]
public static object CreateHandle(
object value,
object values
)
{
return new object();
}
}
```

## Environment

- Excel-DNA: 1.10.0-preview4
- .NET: net8.0-windows
- Excel: Microsoft 365
- Platform: x64
- OS: Windows 11

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.