4

遇到一个奇怪的 Sitecore 错误。使用 MVC 在 Sitecore 6.6 中将布局应用于几个不同的内容项,我收到此错误:

c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\95ad0ba4\20f230f7\App_Web__sitecorelayout.cshtml.5d96958d.682ppzj_.0.cs(24): error CS0234: The type or namespace name 'Kernel' does not exist in the namespace 'Sitecore' (are you missing an assembly reference?)

System.Web.HttpCompileException (0x80004005): c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\95ad0ba4\20f230f7\App_Web__sitecorelayout.cshtml.5d96958d.682ppzj_.0.cs(24): error CS0234: The type or namespace name 'Kernel' does not exist in the namespace 'Sitecore' (are you missing an assembly reference?)
at System.Web.Compilation.AssemblyBuilder.Compile()
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound)
at System.Web.Mvc.BuildManagerWrapper.System.Web.Mvc.IBuildManager.FileExists(String virtualPath)
at System.Web.Mvc.VirtualPathProviderViewEngine.GetPathFromSpecificName(ControllerContext controllerContext, String name, String cacheKey, String[]& searchedLocations)
at System.Web.Mvc.VirtualPathProviderViewEngine.GetPath(ControllerContext controllerContext, String[] locations, String[] areaLocations, String locationsPropertyName, String name, String controllerName, String cacheKeyPrefix, Boolean useCache, String[]& searchedLocations)
at System.Web.Mvc.VirtualPathProviderViewEngine.FindPartialView(ControllerContext controllerContext, String partialViewName, Boolean useCache)
at System.Web.Mvc.ViewEngineCollection.Find(Func`2 lookup, Boolean trackSearchedPaths)
at System.Web.Mvc.HtmlHelper.FindPartialView(ViewContext viewContext, String partialViewName, ViewEngineCollection viewEngineCollection)
at System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection)
at System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData)
at Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer)
at Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Render(Renderer renderer, TextWriter writer, RenderRenderingArgs args)
at Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Process(RenderRenderingArgs args)
at (Object , Object[] )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Mvc.Pipelines.PipelineService.RunPipeline[TArgs](String pipelineName, TArgs args)
at Sitecore.Mvc.Presentation.RenderingView.Render(ViewContext viewContext, TextWriter writer)
at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1c.b__19()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)

IIS 内的构建和应用程序池设置为 4 框架。我不知所措。这种情况发生在同一场景中的任何人身上吗?

4

4 回答 4

8

该问题是由于在 Views 目录中 web.config 文件的命名空间部分中添加了 Sitecore.Kernel 命名空间。删除它解决了问题。

与 Sitecore 支持部门合作解决了该问题。半小时前才想通。

于 2012-09-07T14:55:19.090 回答
1

我的问题是目标框架。当我遇到这个问题时,我正在使用 .NET 4.5。我升级到 .NET 4.6,问题就消失了。

于 2017-05-04T21:56:59.187 回答
0

由于它是动态编译的,也许您可​​以将 sitecore dll 复制到临时 ASP.NET 文件夹中,因为显然它是在您编译而不运行时发生的,因此在 bin 中没有问题?不过只是猜测。

如果这不起作用,也许检查版本或尝试删除临时 ASP.NET 文件夹中的所有内容并重试。

于 2012-09-07T14:03:02.413 回答
0

我遇到过同样的问题。右键单击 References 文件夹 -> 添加引用 -> 浏览 -> 从 bin 文件夹(在您的项目中)中选择 Sitecore.Kernel -> 再次构建解决方案。

于 2013-07-30T02:25:30.483 回答