Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeLoadException in .NET 6 in-process project (dotnet6-playwright branch) after adding package Microsoft.Azure.WebJobs.Extensions.CosmosDB #43

Open
mkb13 opened this issue May 25, 2023 · 0 comments

Comments

@mkb13
Copy link

mkb13 commented May 25, 2023

Note: This is not necessarily a Blazor SWA issue (and I realize I'm using an outdated branch -- see "Background" below) but since Blazor SWA is a particular configuration most people seem unfamiliar with I'm checking here first for ideas.

Repro steps:

  1. Create a project based on blazor-starter, branch dotnet6-playwright.
  2. Follow instructions to start/run the site locally using the "Api" project for Azure functions (Api and Client are startup projects). Observe a working site.
  3. Open Nuget Package Manager and add Microsoft.Azure.WebJobs.Extensions.CosmosDB to the Api project.
  4. Start the project again.

Expected:
Site works the same as before

Actual:
Execution stops with the following exception (see below for call stack):

System.TypeLoadException
  HResult=0x80131522
  Message=Could not load type 'Microsoft.Azure.WebJobs.ParameterBindingData' from assembly 'Microsoft.Azure.WebJobs, Version=3.0.34.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
  Source=Microsoft.Azure.WebJobs.Extensions.CosmosDB

Note: The following alternate steps 2 and 3 do not exhibit the error (using isolated rather than in-process):

  1. Follow instructions to start/run the site locally using the "ApIsolatedi" project for Azure functions (ApiIsolated and Client are startup projects). Observe a working site.
  2. Open Nuget Package Manager and add Microsoft.Azure.**Functions.Worker.**Extensions.CosmosDB to the ApiIsolated project.

Background:
I have a large web app based on the blazor-starter template from last year, when both isolated and in-process were options, and .NET 6.0 was the latest. Since the template default was to use in-process, that's what I used when initially creating my project. My project uses Cosmos DB including CosmosDB binding attributes. I had been using the Cosmos DB .NET SDK v2 and needed to upgrade to v3 for functionality. After doing the initial code update for the Cosmos SDK (not insignificant and must be done all at once), I finally ran it and got this TypeLoadException. I decided to go back to the clean blazor-starter template and try it, and the error still happened. It appears that if I use an isolated process I won't have this problem, However, if there is an easy way to solve this error (e.g. by adding another reference) I would welcome that rather than having to change my project to using an isolated process right now. Cosmos DB bindings are supposed to work with in-process Functions per https://learn.microsoft.com/en-us/azure/azure-functions/functions-add-output-binding-cosmos-db-vs-code?tabs=in-process%2Cv1&pivots=programming-language-csharp so I am not sure if it is something specific with this template.

Callstack:

System.TypeLoadException
  HResult=0x80131522
  Message=Could not load type 'Microsoft.Azure.WebJobs.ParameterBindingData' from assembly 'Microsoft.Azure.WebJobs, Version=3.0.34.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
  Source=Microsoft.Azure.WebJobs.Extensions.CosmosDB
  StackTrace:
   at Microsoft.Azure.WebJobs.Extensions.CosmosDB.CosmosDBExtensionConfigProvider.Initialize(ExtensionConfigContext context)
   at Microsoft.Azure.WebJobs.Host.DefaultExtensionRegistryFactory.Create() in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\DefaultExtensionRegistryFactory.cs:line 38
   at Microsoft.Azure.WebJobs.WebJobsServiceCollectionExtensions.<>c.<AddWebJobs>b__2_0(IServiceProvider p) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Hosting\WebJobsServiceCollectionExtensions.cs:line 57
   at DryIoc.Registrator.<>c__DisplayClass27_0.<RegisterDelegate>b__0(IResolverContext r)
   at DryIoc.Scope.TryGetOrAdd(ImMap`1 items, Int32 id, CreateScopedValue createValue, Int32 disposalOrder)
   at DryIoc.Scope.GetOrAdd(Int32 id, CreateScopedValue createValue, Int32 disposalOrder)
   at DryIoc.Factory.ApplyReuse(Expression serviceExpr, Request request)
   at DryIoc.Factory.GetExpressionOrDefault(Request request)
   at DryIoc.Factory.GetDelegateOrDefault(Request request)
   at DryIoc.Container.DryIoc.IResolver.Resolve(Type serviceType, Object serviceKey, IfUnresolved ifUnresolved, Type requiredServiceType, Request preResolveParent, Object[] args)
   at DryIoc.Scope.TryGetOrAdd(ImMap`1 items, Int32 id, CreateScopedValue createValue, Int32 disposalOrder)
   at DryIoc.Scope.GetOrAdd(Int32 id, CreateScopedValue createValue, Int32 disposalOrder)
   at DryIoc.Factory.ApplyReuse(Expression serviceExpr, Request request)
   at DryIoc.Factory.GetExpressionOrDefault(Request request)
   at DryIoc.Factory.GetDelegateOrDefault(Request request)
   at DryIoc.Container.ResolveAndCacheDefaultFactoryDelegate(Type serviceType, IfUnresolved ifUnresolved)
   at DryIoc.Container.DryIoc.IResolver.Resolve(Type serviceType, IfUnresolved ifUnresolved)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.Azure.WebJobs.WebJobsServiceCollectionExtensions.<>c.<AddWebJobs>b__2_6(IServiceProvider p) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Hosting\WebJobsServiceCollectionExtensions.cs:line 97
   at DryIoc.Registrator.<>c__DisplayClass27_0.<RegisterDelegate>b__0(IResolverContext r)
   at DryIoc.Scope.TryGetOrAdd(ImMap`1 items, Int32 id, CreateScopedValue createValue, Int32 disposalOrder)
   at DryIoc.Scope.GetOrAdd(Int32 id, CreateScopedValue createValue, Int32 disposalOrder)
   at DryIoc.Factory.ApplyReuse(Expression serviceExpr, Request request)
   at DryIoc.Factory.GetExpressionOrDefault(Request request)
   at DryIoc.Factory.GetDelegateOrDefault(Request request)
   at DryIoc.Container.DryIoc.IResolver.Resolve(Type serviceType, Object serviceKey, IfUnresolved ifUnresolved, Type requiredServiceType, Request preResolveParent, Object[] args)
   at DryIoc.Scope.TryGetOrAdd(ImMap`1 items, Int32 id, CreateScopedValue createValue, Int32 disposalOrder)
   at DryIoc.Scope.GetOrAdd(Int32 id, CreateScopedValue createValue, Int32 disposalOrder)
   at DryIoc.Factory.ApplyReuse(Expression serviceExpr, Request request)
   at DryIoc.Factory.GetExpressionOrDefault(Request request)
   at DryIoc.ReflectionFactory.CreateExpressionOrDefault(Request request)
   at DryIoc.Factory.GetExpressionOrDefault(Request request)
   at DryIoc.ReflectionFactory.CreateExpressionOrDefault(Request request)
   at DryIoc.Factory.GetExpressionOrDefault(Request request)
   at DryIoc.Factory.GetDelegateOrDefault(Request request)
   at DryIoc.Container.ResolveAndCacheDefaultFactoryDelegate(Type serviceType, IfUnresolved ifUnresolved)
   at DryIoc.Container.DryIoc.IResolver.Resolve(Type serviceType, IfUnresolved ifUnresolved)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
   at Microsoft.Azure.WebJobs.Script.WebHost.WebJobsScriptHostService.<UnsynchronizedStartHostAsync>d__52.MoveNext()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant