Problem creating reportviewer in asp.net mvc

1

I installed the "Install-Package MvcReportViewer" package via the Package Manager Console and trying to create the ReportViewer gives an error of not finding the reference.

My code:

View

@using MvcReportViewer; <-- Aqui dá erro

<h2>Invoice</h2>
@using (Html.BeginForm("Index", "RelatorioInvoice", FormMethod.Post))
{ 
    <div>
        <label>
           <span>Invoice/Credit note: </span> 
            @Html.TextBox("Range1", "", new { @class = "form-control form-control-custom", style = "width:100px;" }) 

            <span> até </span>
             @Html.TextBox("Range2", "", new { @class = "form-control form-control-custom", style = "width:100px;" })

            <span>Série: </span> 
            @Html.TextBox("txtSerie", "", new { @class = "form-control form-control-custom", style = "width:50px", maxlength = "2" })

            <span>Tipo: </span> 
            @Html.TextBox("Tipo", "", new { @class = "form-control form-control-custom", style = "width:50px;", maxlength = "2" }) 

            <span>CIA: </span>             
            @Html.DropDownList("ItemsListCIA", null, "Sel...", new { @class = "form-control form-control-custom", style = "width:90px;" })

            <input class="btn btn-padrao-bv" type="submit" id="btnPesquisar" value="Pesquisar"/>
            @Html.ActionLink("Comentário", "Comentario", null , new { target = "_blank", @class="modal-link" })

        </label>
        <p>
            <label>
                @ViewBag.Message
            </label>
        </p>
    </div>

}

<script type="text/javascript">

    $(function () {
        $('body').on('click', '.modal-link', function (e) {
            e.preventDefault();
            $(this).attr('data-target', '#modal-container');
            $(this).attr('data-toggle', 'modal');
        });
        $('body').on('click', '.modal-close-btn', function () {
            $('#modal-container').modal('hide');
        });
        $('#modal-container').on('hidden.bs.modal', function () {
            $(this).removeData('bs.modal');
        });
        $('#CancelModal').on('click', function () {
            return false;
        });
    });

</script>

<div style="margin-top: 20px;">

    @Html.MvcReportViewer(
    "/TestReports/TestReport",
    new { Parameter1 = "Hello World!", Parameter2 = DateTime.Now, Parameter3 = 12345, Parameter4 = DateTime.UtcNow },
    new { Height = 900, Width = 900, style = "border: none" })

    <div id="modal-container" class="modal fade comentario-modal" 
    tabindex="-1" role="dialog">

    </div>
</div>
    
asked by anonymous 10.09.2015 / 20:02

1 answer

2
Open the file ~/Views/Web.config (not the root directory, it is another) and add the following entry:

<configuration>
  ...
  <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization"/>
        <add namespace="System.Web.Routing" />
        <add namespace="MvcReportViewer" /> <!-- Esta aqui -->
        <add namespace="MeuProjeto" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>
  ...
</configuration>

If Visual Studio is checking syntax error, close all Views and do a Rebuild in the solution.

    
10.09.2015 / 20:56