Page 1 of 1

Cast Error on Report Designer When Using MVC Route Attribute

Posted: Tue Sep 05, 2017 10:32 pm
by rcollins
Hello,

I'm currently evaluating your software for inclusion in a project I'm working on. Our project is using .NET Core 1.1. Your very helpful chat operator Andrew sent me a link to the GitHub Page for the example project "NET Core Samples".

This sample project runs great, but when I attempt to integrate the Stimulsoft Nuget package into our application I receive the following error:

Code: Select all

System.InvalidCastException: Unable to cast object of type 'Microsoft.AspNetCore.Mvc.Internal.AttributeRoute' to type 'Microsoft.AspNetCore.Routing.Route'.
   at Stimulsoft.Report.NetCore.StiRequestParamsHelper.GetRequestUrl(ViewContext viewContext, String controller, Boolean relativeUrls, Boolean passQueryParams) in D:\Stimulsoft\Stimulsoft.Reports\Stimulsoft.Report.NetCore\Helpers\StiRequestParamsHelper.cs:line 200
   at Stimulsoft.Report.NetCore.StiNetCoreDesigner.Render() in D:\Stimulsoft\Stimulsoft.Reports\Stimulsoft.Report.NetCore\Designer\StiNetCoreDesigner.Render.cs:line 79
   at Stimulsoft.Report.NetCore.StiNetCoreHelper.StiNetCoreDesigner(String id, StiNetCoreDesignerOptions options) in D:\Stimulsoft\Stimulsoft.Reports\Stimulsoft.Report.NetCore\StiNetCoreHelper.cs:line 77
   at AspNetCore._Views_Home_Index_cshtml.<ExecuteAsync>d__21.MoveNext() in /Views/Home/Index.cshtml:line 9
--- 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.Razor.RazorView.<RenderPageAsync>d__14.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.Razor.RazorView.<RenderAsync>d__13.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.ViewFeatures.ViewExecutor.<ExecuteAsync>d__18.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.ViewResult.<ExecuteResultAsync>d__26.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.ControllerActionInvoker.<InvokeResultAsync>d__30.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.ControllerActionInvoker.<InvokeNextResultFilterAsync>d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ResultExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextResourceFilter>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeAsync>d__20.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.<Invoke>d__4.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.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext()
I've tracked the problem down to the fact that our website uses MVC Route attributes. You can easily reproduce the error in the "NET Core Samples" solution (I'm testing with Edit-Report-in-the-Designer project) by adding attributes to the HomeController class:

Code: Select all

    [Route("Home")]
    public class HomeController : Controller
    {...
...and on the Index action method:

Code: Select all

        [Route("Index")]
        public IActionResult Index()
        {
            return View();
        }
When running the project with this modification, you'll have to hit the URL manually to get the error above:

http://localhost:50602/Home/Index

Could you please let me know if there's a way around this problem with our MVC Attribute Routing?

Thanks very much!
Ron Collins

Re: Cast Error on Report Designer When Using MVC Route Attri

Posted: Thu Sep 07, 2017 7:58 am
by Alex K.
Hello,

We reproduced and already fixed the problem, the fix will be available in release 2017.2, which will be available in the end of September.

Thank you.