我从 .Net 4.5 Beta 升级到 RTM 版本,现在当我有一个标准的 WebForm 页面时,我有一个通用的 <asp:RequiredFieldValidator /> 标签,我得到一个如下所示的 NullReferenceException:
[NullReferenceException:对象引用未设置为对象的实例。] System.Web.UI.WebControls.ValidatorCompatibilityHelper.RegisterClientScriptResource(Control control, String resourceName) +180 System.Web.UI.WebControls.BaseValidator.OnPreRender(EventArgs e) +253 System.Web.UI.Control.PreRenderRecursiveInternal() +170 System.Web.UI.Control.PreRenderRecursiveInternal() +255 System.Web.UI.Control.PreRenderRecursiveInternal() +255 System.Web.UI.Control.PreRenderRecursiveInternal () +255 System.Web.UI.Control.PreRenderRecursiveInternal() +255 System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint) +4047
我什至创建了一个示例页面(没有母版页 - 只是下面的 HTML),一旦我添加了验证器,我就会得到上述错误。这是它的HTML:
<form runat="server">
<asp:Textbox runat="server" ID="txTest" />
<asp:RequiredFieldValidator runat="server" ControlToValidate="txTest" />
</form>
此服务器上其他站点的其他页面工作正常,所以我怀疑这与它是 IIS 中的子应用程序有关,而父应用程序是 Orchard。关于我如何解决这个问题的任何建议?由于它只是一个标准标签,我什至不知道从哪里开始寻找。
编辑:我想出了导致它崩溃的原因,尽管我希望果园团队的某个人能够澄清为什么这样做。在默认配置中,有一个正在编译程序集的部分,其中有许多程序集被删除。我把整个列表拿出来,我的内页工作了,所以我开始一次添加它们,当我添加 System.Web.Extensions 的删除条目时它坏了。我可以轻松地将它添加到我的子应用程序中,但我很好奇为什么它会首先被删除。这是它通常的样子,我删除了 System.Web.Extensions 的条目以使我的子应用程序工作:
<compilation debug="false" targetFramework="4.0" batch="true" numRecompilesBeforeAppRestart="250" optimizeCompilations="true">
<buildProviders>
<add extension=".csproj" type="Orchard.Environment.Extensions.Compilers.CSharpExtensionBuildProviderShim" />
</buildProviders>
<assemblies>
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<remove assembly="System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<remove assembly="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<remove assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove assembly="System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<remove assembly="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove assembly="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<remove assembly="System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<remove assembly="System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove assembly="System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove assembly="System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove assembly="System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<remove assembly="System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<remove assembly="System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<remove assembly="System.ServiceModel.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<remove assembly="System.WorkflowServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<remove assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<remove assembly="System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove assembly="System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</assemblies>
</compilation>