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

"MissingMethodException: .ctor" exception occured while updating to OrchardCore version 1.9.0-preview-18162 #15642

Closed
effapp opened this issue Apr 2, 2024 · 10 comments

Comments

@effapp
Copy link

effapp commented Apr 2, 2024

Describe the bug

"MissingMethodException: .ctor" exception occured while updating to OrchardCore version 1.9.0-preview-18162

To Reproduce

Steps to reproduce the behavior:

  1. Open the project that can run normally in OrchardCore version 1.7.2
  2. Update OrchardCore version of the project to 1.9.0-preview-18162
  3. Run the project
  4. The browser display error as follow:

An unhandled exception occurred while processing the request.
MissingMethodException: .ctor
System.RuntimeMethodHandle.IsCAVisibleFromDecoratedType(QCallTypeHandle attrTypeHandle, RuntimeMethodHandleInternal attrCtor, QCallTypeHandle sourceTypeHandle, QCallModule sourceModule)

Stack Query Cookies Headers Routing
MissingMethodException: .ctor
System.RuntimeMethodHandle.IsCAVisibleFromDecoratedType(QCallTypeHandle attrTypeHandle, RuntimeMethodHandleInternal attrCtor, QCallTypeHandle sourceTypeHandle, QCallModule sourceModule)
System.Reflection.CustomAttribute.FilterCustomAttributeRecord(MetadataToken caCtorToken, ref MetadataImport scope, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, bool mustBeInheritable, ref ListBuilder derivedAttributes, out RuntimeType attributeType, out IRuntimeMethodInfo ctorWithParameters, out bool isVarArg)
System.Reflection.CustomAttribute.AddCustomAttributes(ref ListBuilder attributes, RuntimeModule decoratedModule, int decoratedMetadataToken, RuntimeType attributeFilterType, bool mustBeInheritable, ListBuilder derivedAttributes)
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, int decoratedMetadataToken, int pcaCount, RuntimeType attributeFilterType)
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, bool inherit)
Microsoft.AspNetCore.Mvc.ApplicationModels.DefaultApplicationModelProvider.CreateControllerModel(TypeInfo typeInfo)
Microsoft.AspNetCore.Mvc.ApplicationModels.DefaultApplicationModelProvider.OnProvidersExecuting(ApplicationModelProviderContext context)
Microsoft.AspNetCore.Mvc.ApplicationModels.ApplicationModelFactory.CreateApplicationModel(IEnumerable controllerTypes)
Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.GetDescriptors()
Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.OnProvidersExecuting(ActionDescriptorProviderContext context)
Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.UpdateCollection()
Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.Initialize()
Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.GetChangeToken()
Microsoft.Extensions.Primitives.ChangeToken+ChangeTokenRegistration..ctor(Func changeTokenProducer, Action changeTokenConsumer, TState state)
Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func changeTokenProducer, Action changeTokenConsumer)
Microsoft.AspNetCore.Mvc.Routing.ActionEndpointDataSourceBase.Subscribe()
Microsoft.AspNetCore.Builder.ControllerEndpointRouteBuilderExtensions.GetOrCreateDataSource(IEndpointRouteBuilder endpoints)
Microsoft.AspNetCore.Builder.ControllerEndpointRouteBuilderExtensions.MapDynamicControllerRoute(IEndpointRouteBuilder endpoints, string pattern, object state)
OrchardCore.HomeRoute.Startup.Configure(IApplicationBuilder app, IEndpointRouteBuilder routes, IServiceProvider serviceProvider)
OrchardCore.Modules.ShellPipelineExtensions.ConfigurePipelineAsync(IApplicationBuilder builder)
OrchardCore.Modules.ShellPipelineExtensions.BuildPipelineInternalAsync(ShellContext context)
System.Threading.Tasks.ValueTask.get_Result()
OrchardCore.Modules.ShellPipelineExtensions.BuildPipelineAsync(ShellContext context)
OrchardCore.Modules.ModularTenantRouterMiddleware.Invoke(HttpContext httpContext)
OrchardCore.Modules.ModularTenantContainerMiddleware+<>c__DisplayClass4_0+<b__0>d.MoveNext()
OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func<ShellScope, Task> execute, bool activateShell)
OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func<ShellScope, Task> execute, bool activateShell)
OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func<ShellScope, Task> execute, bool activateShell)
OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func<ShellScope, Task> execute, bool activateShell)
OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func<ShellScope, Task> execute, bool activateShell)
OrchardCore.Modules.ModularTenantContainerMiddleware.Invoke(HttpContext httpContext)
Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

Show raw exception details
System.MissingMethodException: .ctor
at System.RuntimeMethodHandle.IsCAVisibleFromDecoratedType(QCallTypeHandle attrTypeHandle, RuntimeMethodHandleInternal attrCtor, QCallTypeHandle sourceTypeHandle, QCallModule sourceModule)
at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(MetadataToken caCtorToken, MetadataImport& scope, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder1& derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctorWithParameters, Boolean& isVarArg) at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder1 derivedAttributes) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit) at Microsoft.AspNetCore.Mvc.ApplicationModels.DefaultApplicationModelProvider.CreateControllerModel(TypeInfo typeInfo) at Microsoft.AspNetCore.Mvc.ApplicationModels.DefaultApplicationModelProvider.OnProvidersExecuting(ApplicationModelProviderContext context) at Microsoft.AspNetCore.Mvc.ApplicationModels.ApplicationModelFactory.CreateApplicationModel(IEnumerable1 controllerTypes)
at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.GetDescriptors()
at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.OnProvidersExecuting(ActionDescriptorProviderContext context)
at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.UpdateCollection()
at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.Initialize()
at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.GetChangeToken()
at Microsoft.Extensions.Primitives.ChangeToken.ChangeTokenRegistration1..ctor(Func1 changeTokenProducer, Action1 changeTokenConsumer, TState state) at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func1 changeTokenProducer, Action changeTokenConsumer)
at Microsoft.AspNetCore.Mvc.Routing.ActionEndpointDataSourceBase.Subscribe()
at Microsoft.AspNetCore.Builder.ControllerEndpointRouteBuilderExtensions.GetOrCreateDataSource(IEndpointRouteBuilder endpoints)
at Microsoft.AspNetCore.Builder.ControllerEndpointRouteBuilderExtensions.MapDynamicControllerRoute[TTransformer](IEndpointRouteBuilder endpoints, String pattern, Object state)
at OrchardCore.HomeRoute.Startup.Configure(IApplicationBuilder app, IEndpointRouteBuilder routes, IServiceProvider serviceProvider)
at OrchardCore.Modules.ShellPipelineExtensions.ConfigurePipelineAsync(IApplicationBuilder builder)
at OrchardCore.Modules.ShellPipelineExtensions.BuildPipelineInternalAsync(ShellContext context)
at OrchardCore.Modules.ShellPipelineExtensions.BuildPipelineAsync(ShellContext context)
at OrchardCore.Modules.ModularTenantRouterMiddleware.Invoke(HttpContext httpContext)
at OrchardCore.Modules.ModularTenantContainerMiddleware.<>c__DisplayClass4_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func2 execute, Boolean activateShell) at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func2 execute, Boolean activateShell) at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Modules.ModularTenantContainerMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

Screenshots

image

@effapp effapp added the bug 🐛 label Apr 2, 2024
@Piedone
Copy link
Member

Piedone commented Apr 3, 2024

1.8.0+ brings breaking changes, including targeting .NET 8, see the release notes. Did you first upgrade your app to v1.8.2?

@effapp
Copy link
Author

effapp commented Apr 3, 2024

Hi @Piedone ,

My app can run normally while upgrading to 1.8.2

@Piedone
Copy link
Member

Piedone commented Apr 3, 2024

Since this doesn't reproduce with the latest source, I assume there's something particular with your setup. Can you check the exception details to see if it shows which type exactly is affected? From what I can tell, there is some issue with an attribute on a model (controller?) class not having a (I guess public) constructor.

@effapp
Copy link
Author

effapp commented Apr 7, 2024

Hi @Piedone ,
Sorry,I can't find location of exception.

I am currently using version 1.8.2 for development and it is running normally.

@Piedone
Copy link
Member

Piedone commented Apr 7, 2024

I mean, you can attach the debugger (like from Visual Studio) and make the exception appear there. Then, the details of the exception object (specifically ClassName) should tell where exactly is the method missing.

@Piedone
Copy link
Member

Piedone commented Apr 11, 2024

@ODA669 since you have this under #15720, could you please provide the info I asked for in my previous comment above?

@effapp
Copy link
Author

effapp commented Apr 11, 2024

I mean, you can attach the debugger (like from Visual Studio) and make the exception appear there. Then, the details of the exception object (specifically ClassName) should tell where exactly is the method missing.

Hi,

Visual studio debugger don't tell me the details of the exception object (specifically ClassName), maybe because the project refference OrchardCore nuget package .

@Piedone
Copy link
Member

Piedone commented Apr 11, 2024

I see. I don't think we'll be able to help you without more information. Can you perhaps share the code somewhere?

@Piedone Piedone added this to the 1.9 milestone Apr 26, 2024
@Piedone
Copy link
Member

Piedone commented Apr 26, 2024

@effapp?

@sebastienros
Copy link
Member

Clean your repository and rebuild, this will get rid of older dlls.

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

No branches or pull requests

3 participants