Search code examples
c#asp.net-mvcrazorteleriktelerik-reporting

Telerik namespace cannot be resolved in ASP.NET MVC Razor view


I'm trying to render Telerik Reporting (Q2 2014 SP1 - trial version) in my ASP.NET MVC 4 application (which uses .NET 4.5 framework), but for some reason "Telerik." namespace cannot be resolved in ASP.NET MVC Razor view, although I can access "Telerik." namespace in controller.

Razor view:

@using Telerik - error is in here
@Html.TelerikReporting() - error is in here

Web.config:

<system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.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.Routing" />
        <add namespace="Telerik.Reporting" />
        <add namespace="Telerik.ReportViewer.Mvc" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>

Telerik libraries my ASP.NET MVC project is referencing:

Telerik.Reporting
Telerik.ReportViewer.Mvc

What can be the issue with my set up?


Solution

  • I solved my problem.

    I've been desperately trying following approaches: running solution in VS2012, deleted bin, obj folders, moving libraries from one path to another, restarting machine and VS numerous times and everything was futile.

    However I've noticed that Telerik.Reporting.dll and Telerik.ReportViewer.Mvc.dll were not getting copied in my bin folder. In Visual Studio I expanded "References", clicked on each dll file and went to each dll's "Properties" and toggled "Copy Local" property from "False" to "True".

    I cleaned and rebuilt my MVC project, checked that the Telerik dll files appeared in bin folder, went to my Razor view and @Html.TelerikReporting() worked!

    Out of curiosity I toggled "Copy Local" property from "True" to "False", repeated the rest of the process and @Html.TelerikReporting() still worked. I don't know if there is a problem with Visual Studio or my "Professional" installation.