1

My Azure Function project (.NET Standard) has a class named Startup.cs that implements an interface IFunctionStartup, as long as this class is in the project the error below is thrown. If I explicitly implement the interface in the class, I can get pass this error, but other classes in the function will then cause the same issue.

Export: Unable to load one or more of the requested types.
Method 'RegisterDependencies' in type '*****.Startup' 
from assembly '*****.AzureFunction, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
does not have an implementation.

Startup.cs

public class Startup : IFunctionStartup
{
    public void RegisterDependencies(ContainerBuilder builder, IConfiguration configuration)
    {
        builder.RegisterModule(new ApplicationRegistrar(configuration));        
    }

    // This explicit interface implementation gets me pass the error,
    // but doesn't address the root cause, because other classes will
    // start failing with the same error.

    //void IFunctionStartup.RegisterDependencies(ContainerBuilder builder, IConfiguration configuration)
    //{
    //    throw new System.NotImplementedException();
    //}
}

IFunctionStartup.cs

public interface IFunctionStartup
{
    void RegisterDependencies(ContainerBuilder builder, IConfiguration configuration);
}

Here is the complete initialization log:

Azure Functions Core Tools (2.3.199 Commit hash: fdf734b09806be822e7d946fe17928b419d8a289)
Function Runtime Version: 2.0.12246.0
[1/11/2019 2:29:54 PM] Starting Rpc Initialization Service.
[1/11/2019 2:29:54 PM] Initializaing RpcServer
[1/11/2019 2:29:54 PM] Building host: startup suppressed:False, configuration suppressed: False
[1/11/2019 2:29:54 PM] Reading host configuration file '*****\host.json'
[1/11/2019 2:29:54 PM] Host configuration file read:
[1/11/2019 2:29:54 PM] {
[1/11/2019 2:29:54 PM]   "version": "2.0"
[1/11/2019 2:29:54 PM] }
[1/11/2019 2:29:55 PM] Initializing Host.
[1/11/2019 2:29:55 PM] Host initialization: ConsecutiveErrors=0, StartupCount=1
[1/11/2019 2:29:55 PM] Starting JobHost
[1/11/2019 2:29:55 PM] Starting Host (HostId=*****-1139087863, InstanceId=2896b355-b2f7-4ae7-bfc4-403ec9c0d84d, Version=2.0.12246.0, ProcessId=247248, AppDomainId=1, InDebugMode=False, InDiagnosticMode=False, FunctionsExtensionVersion=)
[1/11/2019 2:29:55 PM] Loading functions metadata
[1/11/2019 2:29:55 PM] 1 functions loaded
[1/11/2019 2:29:55 PM] WorkerRuntime: dotnet. Will shutdown other standby channels
[1/11/2019 2:29:56 PM] Generating 0 job function(s)
[1/11/2019 2:29:56 PM] Found the following functions:
[1/11/2019 2:29:56 PM] *****.ExportComplianceDetailsFunction.Run
[1/11/2019 2:29:56 PM]
[1/11/2019 2:29:56 PM] Host initialized (754ms)
[1/11/2019 2:29:56 PM] Host started (767ms)
[1/11/2019 2:29:56 PM] Job host started
[1/11/2019 2:29:56 PM] The following 1 functions are in error:
[1/11/2019 2:29:56 PM] Export: Unable to load one or more of the requested types.
[1/11/2019 2:29:56 PM] Method 'RegisterDependencies' in type '*****.Startup' from assembly '*****.AzureFunction, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
[1/11/2019 2:29:56 PM]
Hosting environment: Production
Content root path: *****\netstandard2.0
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
Wagner DosAnjos
  • 6,304
  • 1
  • 15
  • 29
  • 1
    It's most likely a versioning issue. These might help: https://stackoverflow.com/questions/40584562/method-does-not-have-an-implementation-when-loading-assemblies-into-a-new-appdom and https://benohead.com/system-typeloadexception-method-implementation/ – Rufus L Jan 11 '19 at 16:21
  • @RufusL I agree, but it seems an issue outside my code. I have control over both the Startup class and the IFunctionStartup interface and their versions are aligned. It seems some other dependency between the Azure Function Host and my code, but I cannot find a way to troubleshoot it. – Wagner DosAnjos Jan 11 '19 at 17:40
  • I'm still stuck on this one, but so far it seems related to the Azure Functions Host not supporting the latest version of one (or more) nuget packages in my solution. BTW, this is very hard to troubleshoot. – Wagner DosAnjos Jan 15 '19 at 21:17

1 Answers1

1

I was able to resolve the issue. The root cause was Microsoft.EntityFrameworkCore.SqlServer Version 2.2, which is incompatible with Azure Functions at this time.

Unfortunately, the error message is completely unrelated to the root cause and I was only able to figure out the incompatible nuget through trial and error.

Here are some pointers on how to troubleshoot it:

Wagner DosAnjos
  • 6,304
  • 1
  • 15
  • 29