question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid type owner for DynamicMethod

See original GitHub issue

Hi!

i’m on webapi 2, .net 4.51

i’ve installed version 5.0.1 via the package manager with no modifications, when i browse to [root]/swagger/docs/v1 i get the following json

{ “message”: “An error has occurred.”, “exceptionMessage”: “Invalid type owner for DynamicMethod.”, “exceptionType”: “System.ArgumentException”, “stackTrace”: " at System.Reflection.Emit.DynamicMethod.Init(String name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] signature, Type owner, Module m, Boolean skipVisibility, Boolean transparentMethod, StackCrawlMark& stackMark)\r\n at System.Reflection.Emit.DynamicMethod…ctor(String name, Type returnType, Type[] parameterTypes, Type owner, Boolean skipVisibility)\r\n at Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateDynamicMethod(String name, Type returnType, Type[] parameterTypes, Type owner)\r\n at Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateDefaultConstructor[T](Type type)\r\n at Newtonsoft.Json.Serialization.DefaultContractResolver.InitializeContract(JsonContract contract)\r\n at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract(Type objectType)\r\n at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract(Type objectType)\r\n at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract(Type type)\r\n at Swashbuckle.Swagger.SchemaRegistry.CreateInlineSchema(Type type, String refPrefix)\r\n at Swashbuckle.Swagger.SchemaRegistry.GetOrRegister(Type type)\r\n at Swashbuckle.Swagger.SwaggerGenerator.CreateParameter(ApiParameterDescription paramDesc, Boolean inPath, SchemaRegistry schemaRegistry)\r\n at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()\r\n at System.Collections.Generic.List1…ctor(IEnumerable1 collection)\r\n at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)\r\n at Swashbuckle.Swagger.SwaggerGenerator.CreateOperation(ApiDescription apiDescription, SchemaRegistry schemaRegistry)\r\n at Swashbuckle.Swagger.SwaggerGenerator.CreatePathItem(IEnumerable1 apiDescriptions, SchemaRegistry schemaRegistry)\r\n at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer)\r\n at Swashbuckle.Swagger.SwaggerGenerator.GetSwagger(String rootUrl, String apiVersion)\r\n at Swashbuckle.Application.SwaggerDocsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Web.Http.Tracing.Tracers.RequestMessageHandlerTracer.<>c__DisplayClass4.<SendAsync>b__1()\r\n at System.Web.Http.Tracing.ITraceWriterExtensions.TraceBeginEndAsync[TResult](ITraceWriter traceWriter, HttpRequestMessage request, String category, TraceLevel level, String operatorName, String operationName, Action1 beginTrace, Func1 execute, Action2 endTrace, Action`1 errorTrace)\r\n at System.Web.Http.Tracing.Tracers.RequestMessageHandlerTracer.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Web.Http.HttpServer.<SendAsync>d__0.MoveNext()" }

i’ve read through all the documentation, so sorry if i’ve missed something… any clues as to what i’m doing wrong? please let me know if you need any more information, ta!

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
waratahcommented, Sep 6, 2017

In my case I had a base class for the rest of my controllers and the logic was finding this. [ApiExplorerSettings(IgnoreApi = true)] resolved my issue but this is something worthwhile considering while you find the problem.

Nice to have would be a way to record the API call that is generating the error.

2reactions
qwertykeithcommented, Mar 13, 2015

it’s so obvious now, thanks for that! there was some dodgy properties in my webapi base class, i just used [ApiExplorerSettings(IgnoreApi = true)] to hide them and all is good now… thanks! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dapper throws "Invalid type owner for DynamicMethod."
I ran into this error when using an interface instead of the class: Query<MyObject> worked, while Query<IMyObject> did not.
Read more >
Invalid type owner for DynamicMethod when using ...
Basically I just want to force Glass.Mapper to load all the classes during startup. But then I got this strange error in the...
Read more >
[Solved]-Dapper throws "Invalid type owner for DynamicMethod."
it fails because this scenario using query[<t>] isn't expecting an array / sequence of parameters. the execute call-path does expect this, and unrolls...
Read more >
Exception: Invalid type owner for DynamicMethod.
I am a bit lost on this one. It happened with SA5 and happens with SA6 but doesnt (of course) in the non-protected...
Read more >
DynamicMethod and the use of an interface type
{"Invalid type owner for DynamicMethod."} How can i make this DynamicMethod work for interfaces as well? Example: class MyClass :MyInterface
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found