java ascx_CSHTML中ASCX / ASPX的RenderPartial上的Roslyn TypeLoadException

我有一个mvc cshtml视图,其 RenderPartial 是 .ascx .

@* Omitted code *@

@{Html.RenderPartial("~/Views/Vacations/_YearPlanner.ascx", ViewData.Model);}

@* Omitted code *@

这一直有效,直到我将Roslyn编译器添加到项目中,因为我想在 .cs 和 .cshtml 上使用C#6.0 .

这让我安装了两个金块:

Microsoft.CodeDom.Providers.DotNetCompilerPlatform:1.0.8 Microsoft.Net.Compilers:2.3.2(最新版本:2.4.0)

我在安装这些问题时遇到了一些问题,直到我找到了正确的版本组合 .

但现在,我正在处理此页面上的一个问题,该问题呈现出遗留的 ascx 控件 .

发生以下错误:异常类型:HttpCompileException异常消息:外部组件抛出异常 . 位于System.Web.Compilation.Compilation上的System.Web.Compilation.BuildProvidersCompiler.PerformBuild()的System.Web.Compilation.AssemblyBuilder.Compile(),System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath)上的System.Web.Compilation.BuildManager.CompileWebFile(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.Mvc.BuildManagerCompiledView.Render的System.Web.Compilation.BuildManager.GetCompiledType(VirtualPath virtualPath)中的System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath,HttpContext context,Boolean allowCrossApp,Boolean throwIfNotFound)(ViewContext viewContext, System.Web.M上的TextWriter编写器在System.Web.Mvc.WebViewPage.ExecutePageHierarchy()处的System.Web.WebPages.WebPageBase.ExecutePageHierarchy()处的ASP._Views_Vacations_RenderDepartmentMap_cshtml.Execute()处的vc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper htmlHelper,String partialViewName,Object model) System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1过滤器,Int32 filterIndex,System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)中的System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext,TextWriter writer,WebPageRenderingBase startPage)在System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive的System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1过滤器,Int32 filterIndex,ResultExecutingContext preContext,ControllerContext controllerContext,ActionResult actionResult)中的ResultExecutingContext preContext,ControllerContext controllerContext,ActionResult actionResult(IList1过滤器,在System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1)的System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1过滤器,Int32 filterIndex,ResultExecutingContext preContext,ControllerContext controllerContext,ActionResult actionResult)中的Int32 filterIndex,ResultExecutingContext preContext,ControllerContext controllerContext,ActionResult actionResult) System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive中的System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1过滤器,Int32 filterIndex,ResultExecutingContext preContext,ControllerContext controllerContext,ActionResult actionResult)中的过滤器,Int32 filterIndex,ResultExecutingContext preContext,ControllerContext controllerContext,ActionResult actionResult) System.Web.Mvc.ControllerActionInvoker中的(IList1过滤器,Int32 filterIndex,ResultExecutingContext preContext,ControllerContext controllerContext,ActionResult actionResult) . 系统中的System.Web.Mvc.Controller.b__1d(IAsyncResult asyncResult,ExecuteCoreState innerState)上的System.Web.Mvc.Async.AsyncControllerActionInvoker . <> c__DisplayClass21.b__1e(IAsyncResult asyncResult)中的InvokeActionResultWithFilters(ControllerContext controllerContext,IList1过滤器,ActionResult actionResult)系统中System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult)的System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)中的.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) .Web.Mvc.MvcHandler.b__5(IAsyncResult asyncResult,ProcessRequestState innerState)at atSystem.Web.HttpApplication.ExecuteStep(IExecutionStep步骤)的System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()中的System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) ,布尔和完成异步)

当我从webconfig中删除以下行时,此控件开始工作:

这是由包 Microsoft.CodeDom.Providers.DotNetCompilerPlatform 自动添加的 .

我需要保留这条线吗?我仍然需要那些C#6.0功能 .

我是否需要添加一些东西来编译 aspx 和 ascx 与roslyn?

Edit 1

它适用于我的机器,但不适用于服务器 .

Edit 2

InnerException - 外部组件抛出异常 .

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值