Azure / Azure/azure-functions-host

The method '{methodName}' cannot be found.

Open
#2,872 1 comment 0 reactions 1 assignee Claimed by @fabiocav View on GitHub
bug
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 12h
Merged PRs (30d)
38

Description

If you try to create a Function that is not static, you will get an error message at runtime like:

> The method 'SomeName' cannot be found.

What's weird about the error message is that it knows enough to tell us what the method name is, since it is there, but then can't find it.

```csharp
[FunctionName("SomeFunction))]
public async Task SomeName([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]HttpRequest req)
```

From what I can tell, the build step is generating the `function.json` using the defined method, whether static or not. And then at runtime, only `static` is used for binding.

https://github.com/Azure/azure-functions-host/blob/dev/src/WebJobs.Script/Description/DotNet/Compilation/Raw/RawAssemblyCompilation.cs#L54

In v1, I was able to use non-static methods, so this is a breaking change in v2. The reason I want to use non-static, is because I like to create a function base class for shared functionality.

Was there a conscious decision to disallow non-static methods? If so, why?

#### Related information

* C#
* Microsoft.NET.Sdk.Functions 1.0.13

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.