简体   繁体   English

web.config中对同一dll的多个引用

[英]Multiple references to the same dll in web.config

I have a web application (asp.net webforms) that uses telerik controls, such as telerik:ReportViewer and telerik:RadTimePicker. 我有一个使用Telerik控件(例如telerik:ReportViewer和telerik:RadTimePicker)的Web应用程序(asp.net Webforms)。

The interesting part is, the telerik library extensively uses the same dll (eg System.Web.Extensions), causing IIS Manager to issue "Duplicate Reference" error. 有趣的是,telerrik库广泛使用相同的dll(例如System.Web.Extensions),从而导致IIS管理器发出“重复引用”错误。 Trying to simply delete the duplicate references causes some parts of the website to stop working. 尝试简单地删除重复的引用会导致网站的某些部分停止工作。

How can I make same references to a single DLL within Web.config , without having to add duplicates?? 如何在Web.config对单个DLL进行相同的引用,而不必添加重复项?

Look why: 看为什么:

<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
                <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
                <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
                    <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
                    <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
                    <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
                    <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
                </sectionGroup>
            </sectionGroup>
        </sectionGroup>
    </configSections>

IIS reports duplicate references for each section element above. IIS报告上面每个section元素的重复引用。 Deleting them causes the time picker to not show when clicked. 删除它们会导致时间选择器在单击时不显示。

The same references goes in other places: 相同的引用在其他地方:

<compilation debug="true">
            <assemblies>
                ...
                <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                ...
                <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                ...
        </compilation>

And also: 并且:

<httpModules>
    <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>

<modules>
    <remove name="ScriptModule"/>
    <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</modules>

When running using Visual Studio (Debugging), everything fine. 使用Visual Studio(调试)运行时,一切正常。 But once deployed to IIS, IIS reports errors of duplicates!! 但是一旦部署到IIS,IIS就会报告重复错误!!

It seems your website has been updated from old .NET versions and has become a mess of sections that newer .NET versions do not need. 您的网站似乎已从旧的.NET版本进行了更新,并变成了新的.NET版本不需要的部分内容。 VS does not really rung on IIS by default so it probably does not read the entire web.config, hence things working on dev. 默认情况下,VS并不是真正在IIS上运行,因此它可能无法读取整个web.config,因此可以在dev上运行。

So, what you can try is: 因此,您可以尝试的是:

  • start a new blank WebForms application targetting .NET 4 or .NET 4.5 , depending on what you target and copy its web.config. 启动一个新的空白WebForms应用程序,目标是.NET 4或.NET 4.5,具体取决于您要定位的目标并复制其web.config。 What you need to make sure is that you can run MS AJAX properly, so a simple asp:UpdatePanel on the page should let you have a working page first. 您需要确保可以正确运行MS AJAX,因此页面上的简单asp:UpdatePanel应该让您首先拥有一个工作页面。 This includes making sure all webresource requests pass. 这包括确保所有网络资源请求均通过。

  • see what you need to add for Telerik's controls here: http://www.telerik.com/help/aspnet-ajax/web-config-settings-overview.html#mandatory-additions . 在此处查看需要添加Telerik控件的内容: http : //www.telerik.com/help/aspnet-ajax/web-config-settings-overview.html#mandatory-additions It is just a few handlers, those sections that error out are used by the core MS AJAX functionality. 只是一些处理程序,那些出错的部分由核心MS AJAX功能使用。

  • try adding bindingRedirect element for the old Web.Extensions assembly to the new one. 尝试将旧的Web.Extensions程序集的bindingRedirect元素添加到新的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM