0

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?

2
  • Which web.config did you add this to? You need to add it to the web.config under the Views folder. Commented Aug 6, 2014 at 18:43
  • This is Views/web.config Commented Aug 7, 2014 at 8:06

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

You shouldn't need a

@using Telerik 

if the appropriate namespaces are imported in your web.config. Sometimes in order for your Razer views to pick up on the web.config namespaces after being initially added, you need to restart visual studio for some reason.

I would validate that "Telerik" is the appropriate namespace for the TelerikReporting method you're trying to access.

Additionally, you have a syntax error in:

@Html.TelerikReporting()

It should (likely) be

@(Html.TelerikReporting())

2 Comments

Tried with brackets, still doesn't work. Also I've tried to clean/rebuild the solution - nothing. Restarted Visual Studio - nothing. Restarted PC - nothing.
"@using Telerik" is just to show that this namespace doesn't appear neither in IntelliSence, nor in runtime compilation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.