I had everything working well. But then I decided to move one type DateTimeRange
to separate project (DLL in the same solution). Also I changed namespace from XYZ.ABC
to XYZ.DEF
.
It works fine in Visual Studio, but after I published site on IIS
, it throws exception.
System.Web.HttpCompileException (0x80004005)
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\...\App_Web__viewName.cshtml.a05ae3fa.cybothwk.0.cs(31):
error CS0234: The type or namespace name 'DateTimeRange' does not exist in the namespace 'XYZ.ABC' (are you missing an assembly reference?)
It says it cannot find DateTimeRange
in namespace XYZ.ABC
. But I have updated the view to use model from updated namespace.
I tried to clear ASP.NET temporary files, but it didn't help.
I have references to 2nd project with copy local
set to true.
1)The first thing you need to check was if the class library's reference in the ASP.NET MVC project had the "Copy Local" property set to true.
2)add the namespace that it couldn't find manually inside the tag in the web.config file under Views folder (not root folder web.config file):
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization"/>
...
</namespaces>
3)tried to add namespace directly to the view itself that is causing the problem. add the @using directive at the beginning of the view:
@using MyCustomClass;
4)need to check the properties of a class project:
User contributions licensed under CC BY-SA 3.0