+1-888-365-2779
Try Now
More in this section

Forums / Project Feather / Sitefinity 8.1 - System.Web.HttpCompileException, The type or namespace name 'Mvc' could not be found (are you missing a using directive or an assembly reference

Sitefinity 8.1 - System.Web.HttpCompileException, The type or namespace name 'Mvc' could not be found (are you missing a using directive or an assembly reference

2 posts, 0 answered
  1. Joe
    Joe avatar
    2 posts
    Registered:
    30 Mar 2015
    15 Aug 2015
    Link to this post

    Hi, I thought I'd share an issue I was facing and my solution.

    Setup:

    * VS2012,

    * Sitefinity 8.1 with Feather module installed

    * using Telerkik.Sitefinity.All  nuget packages instead of relying on default bin folder assemblies

    * Hosted in IIS (not using IIS Express)

    * Added a custom widget to SitefinityWebApp by referencing external assembly

    * My custom widget uses an embedded razor view (Index.cshtml Build Action:embedded resource)

    I followed feather tutorial but kept getting and error (in Error.log) when dropping the widget on to a page:

    Type : System.Web.HttpCompileException, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    Message : c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\0b3d364d\789bd827\App_Web_index.cshtml#bootstrap.cshtml.4c64411f.5msnie6e.0.cs(28): error CS0246: The type or namespace name 'Mvc' could not be found (are you missing a using directive or an assembly reference?)

    After trial and error (hours) and numerous nuget Uninstall and Install-Package it turned out to be quite a simple fix.

     

    Solution: Always Include the fully qualified name in your razor view when referencing your model in a custom external library.  Resharper suggested I can remove the fully qualified path which introduced the issue.

    For example :Index.cshtml 

    Wrong: @model Mvc.Models.MyWidget

    Correct: @model MyCompany.Sitefinity.Frontend.MyWidgets.Mvc.Models.MyWidget

     

  2. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    29 Nov 2016
    18 Aug 2015
    Link to this post
    Hi Joe,

    Thank you for the shared solution.

    In addition, more information about how to create MVC widget in a separate assembly could be found here:
    http://docs.sitefinity.com/feather-create-widgets.

    Regards,
    Svetoslav Manchev
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
2 posts, 0 answered