Azure / Azure/azure-functions-host

NCrontab.Signed is not listed in runtimeassemblies.json

Open
#6,691 1 comment 0 reactions 1 assignee Claimed by @brettsam View on GitHub
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 10h
Merged PRs (30d)
36

Description

We have `NCrontab` listed -- but this isn't the assembly that we actually use -- it's `NCrontab.Signed`.

Repro:

```
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Timers;
using Microsoft.Extensions.Logging;
using NCrontab;

namespace FunctionAppCronTimer
{
public static class Function1
{
[FunctionName("Function1")]
public static void Run([TimerTrigger("0 */5 * * * *", RunOnStartup = true)] TimerInfo myTimer, ILogger log)
{
new CronSchedule(CrontabSchedule.Parse("*/5 * * * *"));
}
}
}
```

This fails with:
```
Executed 'Function1' (Failed, Id=d1175734-a61f-41f1-a9bb-e7fc7e46ee7e, Duration=468ms)
System.Private.CoreLib: Exception while executing function: Function1. FunctionAppCronTimer: Method not found: 'Void Microsoft.Azure.WebJobs.Extensions.Timers.CronSchedule..ctor(NCrontab.CrontabSchedule)'.
```

Because we don't see `NCrontab.Signed` listed as one of our assemblies, we load the one from the bin folder, meaning we have two versions loaded. When that happens, the call to create the `CronSchedule` exists only in the Host AssemblyLoadContext yet `NCrontab` exists in both contexts -- so this Assembly is not recognized and you get the confusing reflection-related error.

The workaround is to explicitly remove this assembly from your output, which will force the assembly to load in only the Host context:

```







```

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.