Azure-functions-core-tools: System.ComponentModel.Annotatoins Version=4.2.0.0 (doesn't exist)

Created on 16 May 2018  路  16Comments  路  Source: Azure/azure-functions-core-tools

Originally filed as https://github.com/aspnet/EntityFrameworkCore/issues/12010 by @codputer

I'm attempting to execute an Azure Function, referencing my .Net 2.0 libraries to manage entities in my domain model. The code works in both test project (4.7), as well as a console application (4.7), but when I invoke the same code from Azure Function, I get an error from EntityFramwork that is referencing a Annotation library that does NOT exist... not sure if this should to Azure Functions, but it lists that EF Core cannot load a library - and that library version (4.2.0.0) does not exist.

here is the full stack of the error:

Listening on http://localhost:7071/
Hit CTRL-C to exit...
[2018-05-15 3:52:32 PM] Reading host configuration file 'C:\Users\codputer\Source\Repos\SnapChing20183\SnapChing.API\bin\Debug\net47host.json'
[2018-05-15 3:52:32 PM] Host configuration file read:
[2018-05-15 3:52:32 PM] {}
[2018-05-15 3:52:32 PM] Starting Host (HostId=phxhomeoffice-1714292193, Version=1.0.11702.0, InstanceId=xxxx, ProcessId=31732, AppDomainId=1, Debug=False, ConsecutiveErrors=0, StartupCount=1, FunctionsExtensionVersion=)
[2018-05-15 3:52:33 PM] Loaded custom extension 'BotFrameworkConfiguration'
[2018-05-15 3:52:33 PM] Loaded custom extension 'SendGridConfiguration'
[2018-05-15 3:52:33 PM] Loaded custom extension 'EventGridExtensionConfig'
[2018-05-15 3:52:33 PM] registered EventGrid Endpoint = http://localhost:7071/admin/extensions/EventGridExtensionConfig
[2018-05-15 3:52:33 PM] Generating 1 job function(s)
[2018-05-15 3:52:33 PM] Found the following functions:
[2018-05-15 3:52:33 PM] VendorAPI.VendorMaintenance.Run
[2018-05-15 3:52:33 PM]
[2018-05-15 3:52:33 PM] Host initialized (984ms)
[2018-05-15 3:52:33 PM] Host started (1063ms)
[2018-05-15 3:52:33 PM] Job host started
[2018-05-15 3:52:34 PM] Host lock lease acquired by instance ID '000000000000000000000000E59D0BE9'.
[2018-05-15 3:52:34 PM] Executing HTTP request: {
[2018-05-15 3:52:34 PM] "requestId": "xxxxx,
[2018-05-15 3:52:34 PM] "method": "GET",
[2018-05-15 3:52:34 PM] "uri": "/"
[2018-05-15 3:52:34 PM] }
[2018-05-15 3:52:34 PM] Executed HTTP request: {
[2018-05-15 3:52:34 PM] "requestId": "xxxxx",
[2018-05-15 3:52:34 PM] "method": "GET",
[2018-05-15 3:52:34 PM] "uri": "/",
[2018-05-15 3:52:34 PM] "authorizationLevel": "Anonymous",
[2018-05-15 3:52:34 PM] "status": "OK"
[2018-05-15 3:52:34 PM] }

Http Functions:

    VendorRegistration: http://localhost:7071/api/VendorRegistration

Debugger listening on [::]:5858
[2018-05-15 3:53:22 PM] Executing HTTP request: {
[2018-05-15 3:53:22 PM] "requestId": "xxxxx",
[2018-05-15 3:53:22 PM] "method": "POST",
[2018-05-15 3:53:22 PM] "uri": "/api/VendorRegistration"
[2018-05-15 3:53:22 PM] }
[2018-05-15 3:53:22 PM] Function started (Id=xxxxx[2018-05-15 3:53:22 PM] Executing 'VendorRegistration' (Reason='This function was programmatically called via the host APIs.', Id=xxxxx)
[2018-05-15 3:53:22 PM] Processing Vendor Managment Request
[2018-05-15 3:53:32 PM] A ScriptHost error has occurred
[2018-05-15 3:53:32 PM] Exception while executing function: VendorRegistration. Microsoft.EntityFrameworkCore: Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
[2018-05-15 3:53:32 PM] Exception while executing function: VendorRegistration
[2018-05-15 3:53:32 PM] Exception while executing function: VendorRegistration. Microsoft.EntityFrameworkCore: Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
[2018-05-15 3:53:32 PM] Function completed (Failure, Id=96f3b6cc-fb77-4766-8f15-92919c31d2b6, Duration=10177ms)
[2018-05-15 3:53:32 PM]
[2018-05-15 3:53:32 PM] Executed 'VendorRegistration' (Failed, Id=96f3b6cc-fb77-4766-8f15-92919c31d2b6)
[2018-05-15 3:53:32 PM] mscorlib: Exception while executing function: VendorRegistration. Microsoft.EntityFrameworkCore: Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
[2018-05-15 3:53:32 PM] Function had errors. See Azure WebJobs SDK dashboard for details. Instance ID is '96f3b6cc-fb77-4766-8f15-92919c31d2b6'
[2018-05-15 3:53:32 PM] mscorlib: Exception while executing function: VendorRegistration. Microsoft.EntityFrameworkCore: Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
[2018-05-15 3:53:32 PM] {"id":"d03237fa-8390-4ac0-9c1e-49c5f75b1091","requestId":"9c2560a4-f24d-4fb6-b8d3-3ff3fec7d3ad","statusCode":500,"errorCode":0,"message":"Exception while executing function: VendorRegistration -> Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.","errorDetails":"Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: VendorRegistration ---> System.IO.FileNotFoundException : Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.\r\n at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.CoreConventionSetBuilder.CreateConventionSet()\r\n at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateConventionSet(IConventionSetBuilder conventionSetBuilder)\r\n at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel(DbContext context,IConventionSetBuilder conventionSetBuilder,IModelValidator validator)\r\n at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.<>c__DisplayClass5_0.b__1()\r\n at System.Lazy1.CreateValue()\r\n at System.Lazy1.LazyInitValue()\r\n at System.Lazy1.get_Value()\r\n at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.GetModel(DbContext context,IConventionSetBuilder conventionSetBuilder,IModelValidator validator)\r\n at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel()\r\n at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model()\r\n at Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder.<>c.<TryAddCoreServices>b__7_1(IServiceProvider p)\r\n at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite,ServiceProviderEngineScope scope)\r\n at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(IServiceCallSite callSite,TArgument argument)\r\n at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite,ServiceProviderEngineScope scope)\r\n at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(IServiceCallSite callSite,TArgument argument)\r\n at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite,ServiceProviderEngineScope scope)\r\n at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(IServiceCallSite callSite,TArgument argument)\r\n at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite,ServiceProviderEngineScope scope)\r\n at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(IServiceCallSite callSite,TArgument argument)\r\n at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)\r\n at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType,ServiceProviderEngineScope serviceProviderEngineScope)\r\n at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)\r\n at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider,Type serviceType)\r\n at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)\r\n at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()\r\n at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider()\r\n at Microsoft.EntityFrameworkCore.DbContext.Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<System.IServiceProvider>.get_Instance()\r\n at Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade.Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<System.IServiceProvider>.get_Instance()\r\n at Microsoft.EntityFrameworkCore.Internal.InternalAccessorExtensions.GetService[TService](IInfrastructure1 accessor)\r\n at Microsoft.EntityFrameworkCore.Infrastructure.AccessorExtensions.GetService[TService](IInfrastructure1 accessor)\r\n at Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade.get_DatabaseCreator()\r\n at Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade.EnsureCreated()\r\n at async VendorAPI.VendorMaintenance.Run(HttpRequestMessage req,TraceWriter log)\r\n at async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker2.InvokeAsyncTReflected,TReturnValue\r\n at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker,ParameterHelper parameterHelper,CancellationTokenSource timeoutTokenSource,CancellationTokenSource functionCancellationTokenSource,Boolean throwOnTimeout,TimeSpan timerInterval,IFunctionInstance instance)\r\n at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance instance,ParameterHelper parameterHelper,TraceWriter traceWriter,CancellationTokenSource functionCancellationTokenSource)\r\n at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??)\r\n at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) \r\n End of inner exception\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??)\r\n at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance,CancellationToken cancellationToken)\r\n at Microsoft.Azure.WebJobs.Host.Executors.ExceptionDispatchInfoDelayedException.Throw()\r\n at async Microsoft.Azure.WebJobs.JobHost.CallAsync(??)\r\n at async Microsoft.Azure.WebJobs.Script.ScriptHost.CallAsync(String method,Dictionary2 arguments,CancellationToken cancellationToken)\r\n at async Microsoft.Azure.WebJobs.Script.WebHost.WebScriptHostManager.HandleRequestAsync(FunctionDescriptor function,HttpRequestMessage request,CancellationToken cancellationToken)\r\n at async Microsoft.Azure.WebJobs.Script.Host.FunctionRequestInvoker.ProcessRequestAsync(HttpRequestMessage request,CancellationToken cancellationToken,WebScriptHostManager scriptHostManager,WebHookReceiverManager webHookReceiverManager)\r\n at async Microsoft.Azure.WebJobs.Script.WebHost.Controllers.FunctionsController.<>c__DisplayClass3_0.<ExecuteAsync>b__0(??)\r\n at async Microsoft.Azure.WebJobs.Extensions.Http.HttpRequestManager.ProcessRequestAsync(HttpRequestMessage request,Func3 processRequestHandler,CancellationToken cancellationToken)\r\n at async Microsoft.Azure.WebJobs.Script.WebHost.Controllers.FunctionsController.ExecuteAsync(HttpControllerContext controllerContext,CancellationToken cancellationToken)\r\n at async System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)\r\n at async System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)\r\n at async System.Web.Http.Cors.CorsMessageHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)\r\n at async Microsoft.Azure.WebJobs.Script.WebHost.Handlers.WebScriptHostHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)\r\n at async Microsoft.Azure.WebJobs.Script.WebHost.Handlers.SystemTraceHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)\r\n at async System.Web.Http.HttpServer.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)"}
[2018-05-15 3:53:32 PM] mscorlib: Exception while executing function: VendorRegistration. Microsoft.EntityFrameworkCore: Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Most helpful comment

Temporary fix that that uses assembly redirection worked for me: https://stackoverflow.com/a/50776946/2705777

All 16 comments

@ajcvickers do you still see this issue with the latest version of the runtime/CLI?

@fabiocav You'll need to ask @codputer. I just moved the bug.

@fabiocav I receive a similar issue when trying to run my function. I've got a reference to version System.ComponentModel.Annotations 4.5.0 in my functions csproj directly but receive the following.

[08/06/2018 10:20:25] A ScriptHost error has occurred
[08/06/2018 10:20:25] Exception while executing function: PTL_SparkPostEmailSender. Microsoft.EntityFrameworkCore: Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
[08/06/2018 10:20:25] Exception while executing function: PTL_SparkPostEmailSender
[08/06/2018 10:20:25] Exception while executing function: PTL_SparkPostEmailSender. Microsoft.EntityFrameworkCore: Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
[08/06/2018 10:20:25] Function completed (Failure, Id=972360be-b331-4076-8248-f7409319a012, Duration=101ms)
[08/06/2018 10:20:25]
[08/06/2018 10:20:25] Executed 'PTL_SparkPostEmailSender' (Failed, Id=972360be-b331-4076-8248-f7409319a012)
[08/06/2018 10:20:25] mscorlib: Exception while executing function: PTL_SparkPostEmailSender. Microsoft.EntityFrameworkCore: Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
[08/06/2018 10:20:25] Function had errors. See Azure WebJobs SDK dashboard for details. Instance ID is '972360be-b331-4076-8248-f7409319a012'
[08/06/2018 10:20:25] mscorlib: Exception while executing function: PTL_SparkPostEmailSender. Microsoft.EntityFrameworkCore: Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Any idea how to solve this?

FYI I'm using:
VS 15.7.3
Azure Functions and Web Jobs Tools 15.0.40502.0
EF Core 2.1

I have a same issue after update my project from asp.net core 2.0.3 to 2.1.0. The website is running ok but azure function project report "Microsoft.EntityFrameworkCore: Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies" during execution.

Everybody help me?

@cecbr That's exactly what I have done to end up with the error, hopefully someone will check this today. Don't think they are at work yet :)

I just posted on StackOverflow how I got it to work...

https://stackoverflow.com/questions/50342416/azure-function-ef-core-cant-load-componentmodel-annotations-4-2-0-0/50770897#50770897

This may not work for all the "File Not Found" assembly errors, but it did solve the Annotations one.

I had the same problem and what I ended up doing was to downgrade the Microsoft.EntityFrameworkCore package to version 2.0.3 which has a dependency on System.ComponentModel.Annotations 4.4.0 which is the package that the Microsoft.NET.Sdk.Functions 1.0.14 requires. If you have an explicit dependency on System.ComponentModel.Annotations 4.5.0 or greater you need to downgrade that to 4.4.0 as well.

Azure functions dependencies are a little all over the place right now. Facing a lot of difficulties with the move to .net core 2.1

Ya, this sucks. Spent 5 hours on this today. after I already spent an entire day with a workaround on getting binding redirects working. Of course, that didn't work with annotations. Will try @RoySalisbury 's solution. MS really needs to fix this. I'm on a project with only functions and it's been nothing short of DLL hell along the way.

@bbqchickenrobot some of the comments here have different root causes. Can you please open an issue here with details about your scenario and, more importantly, the runtime version you're using. With recent 2.0 preview releases, significant enhancements were made to assembly binding and resolution, and most of the binding related issues should be addressed there, so I'm curious to get more details on the issues you're seeing. Thanks!

Got it fixed @fabiocav - turns out it was the version number. Also, glad to here v2 has a lot of upcoming changes re: binding redirects. Would remove a ton of headache! I would go that route now but unfortunately, v2 isn't production ready just yet.... or is it!?

Not yet, but it will be before the end of the year.

Temporary fix that that uses assembly redirection worked for me: https://stackoverflow.com/a/50776946/2705777

I'm having this issue as well. I've been reading through a few of your threads @ajcvickers and only @neil-rubens temporary fix is the only thing that works for me.

Is there any (planned) progress on this issue? The last activity is almost one year old in spite of the fact that this issue still happens...

Closed as resolved

Was this page helpful?
0 / 5 - 0 ratings