nbarbettini / BeautifulRestApi

Beautiful REST API design with ASP.NET Core and Ion
Apache License 2.0
605 stars 145 forks source link

System.Reflection.TargetParameterCountException: Parameter count mismatch. #9

Open sagarkul opened 6 years ago

sagarkul commented 6 years ago

I have MyResource.cs contains List and List. Here I am getting an error as follow.

System.Reflection.TargetParameterCountException: Parameter count mismatch. at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index) at CareMentor.Web.Filters.LinkRewritingFilter.RewriteLinksInNestedObjects(IEnumerable1 objectProperties, Object obj, LinkRewriter rewriter) in C:\Web\Filters\LinkRewritingFilter.cs:line 95 at CareMentor.Web.Filters.LinkRewritingFilter.RewriteAllLinks(Object model, LinkRewriter rewriter) in C:\Web\Filters\LinkRewritingFilter.cs:line 79 at CareMentor.Web.Filters.LinkRewritingFilter.RewriteLinksInNestedObjects(IEnumerable1 objectProperties, Object obj, LinkRewriter rewriter) in C:\Web\Filters\LinkRewritingFilter.cs:line 95 at CareMentor.Web.Filters.LinkRewritingFilter.RewriteAllLinks(Object model, LinkRewriter rewriter) in C:\Web\Filters\LinkRewritingFilter.cs:line 79 at CareMentor.Web.Filters.LinkRewritingFilter.RewriteLinksInArrays(IEnumerable1 arrayProperties, Object obj, LinkRewriter rewriter) in C:\Web\Filters\LinkRewritingFilter.cs:line 111 at CareMentor.Web.Filters.LinkRewritingFilter.RewriteAllLinks(Object model, LinkRewriter rewriter) in C:\Web\Filters\LinkRewritingFilter.cs:line 76 at CareMentor.Web.Filters.LinkRewritingFilter.d2.MoveNext() in C:\Web\Filters\LinkRewritingFilter.cs:line 38 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d24.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d22.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d17.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d15.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Builder.RouterMiddleware.d4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.d7.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.d3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.ResponseCaching.ResponseCachingMiddleware.d9.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.d6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.d6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at CareMentor.Web.Startup.<>c.<b5_0>d.MoveNext() in C:\Web\Startup.cs:line 149 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.d__6.MoveNext()`

nbarbettini commented 6 years ago

Interesting! I'll take a look at this when I can. Are you following my video course, or just trying out this code yourself?

Can you paste your MyResource definition?

carlosmacbeath commented 6 years ago

I' m geeting and error using net core 2 pastedimage

sagarkul commented 6 years ago

here is my resource class

public class MyResource { public ChannelDetailResource ChannelDetail { get; set; } public string TopicName { get; set; } public string TopicDescription { get; set; } [JsonConverter(typeof(StringEnumConverter))] public MediaType MediaType { get; set; } public string ThumbnailUrl { get; set; } public string ContentUrl { get; set; } [JsonConverter(typeof(StringEnumConverter))] public List<ContentCategory> Categories { get; set; } [JsonConverter(typeof(StringEnumConverter))] public List<Disease> Diseases { get; set; } public string Source { get; set; } [JsonConverter(typeof(StringEnumConverter))] public ContentLevel Level { get; set; } public string Notes { get; set; } public string CuratedBy { get; set; } public string Language { get; set; } public double Duration { get; set; } public bool View { get; set; } public bool Like { get; set; } public bool Dislike { get; set; } }

rclanan commented 6 years ago

public class MyResource : Resource

You need to make sure it inherits from Resource or you will see that error.