azure-functions-core-tools: System.ComponentModel.Annotatoins Version=4.2.0.0 (doesn't exist)
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\net47\host.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.<GetModel>b__1()\r\n at System.Lazy1.CreateValue()\r\n at System.Lazy
1.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.CallSiteVisitor
2.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.CallSiteVisitor
2.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](IInfrastructure
1 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.FunctionInvoker
2.InvokeAsync[TReflected,TReturnValue](Object instance,Object[] arguments)\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,Func
3 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.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (4 by maintainers)
Temporary fix that that uses assembly redirection worked for me: https://stackoverflow.com/a/50776946/2705777
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
@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!
@ajcvickers do you still see this issue with the latest version of the runtime/CLI?