0

这个问题与堆栈溢出 ESB 工具包和企业库冲突中提出的问题类似

我已经尝试了建议的解决方案,但仍然无法让我的 Web 服务正常工作。

有没有人对此有答案,我也有类似的问题。Biztalk ESB 已安装,它破坏了我的 web.config。

这就是我的 web.config 的样子

    <configSections>
     <section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
  </configSections>

  <enterpriseLibrary.ConfigurationSource selectedSource="EntLib File-based Configuration Source SomeThingElse">
    <sources>
      <add name="EntLib File-based Configuration Source SomeThingElse" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" filePath="WebEntLib.config" />
    </sources>
    <redirectSections>
      <add sourceName="EntLib File-based Configuration Source SomeThingElse" name="loggingConfiguration" />
    </redirectSections>
  </enterpriseLibrary.ConfigurationSource>

这就是我的 webEntLib.config 的样子。

    <configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
  </configSections>
  <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
    <listeners>
      <add name="Rolling Flat File Trace Listener"
          type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
          listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
          footer="" formatter="Text Formatter" header="" rollInterval="Day"
          rollSizeKB="1024" maxArchivedFiles="5" fileName="D:\Temp\logs\SomeThingElse\SomeThingElseTrace.log"/>
    </listeners>
    <formatters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
           template="{timestamp} - [{severity}] : {category} {eventid} - {message}"
           name="Text Formatter" />
    </formatters>
    <categorySources>
      <add switchValue="All" name="General">
        <listeners>
          <add name="Rolling Flat File Trace Listener" />
        </listeners>
      </add>
      <add switchValue="All" name="Debug">
        <listeners>
          <add name="Rolling Flat File Trace Listener" />
        </listeners>
      </add>
    </categorySources>
    <specialSources>
      <allEvents switchValue="Off" name="All Events" />
      <notProcessed switchValue="Off" name="Unprocessed Category" />
      <errors switchValue="All" name="Logging Errors &amp; Warnings">
        <listeners>
          <add name="Rolling Flat File Trace Listener" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>

我什至尝试了您在 web.config 和 webEntLib.config 中都进行重定向的建议。

      <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Practices.EnterpriseLibrary.Common" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="4.1.0.0" newVersion="5.0.505.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Practices.EnterpriseLibrary.Logging" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="4.1.0.0" newVersion="5.0.505.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

有关 dll 重定向的 Microsoft 文章位于以下链接 Redirecting Assembly Versions

但它似乎不起作用。我做错了什么或者我还能做什么?

我什至在网站的 bin 文件夹中添加了一个专用的 Microsoft.Practices.EnterpriseLibrary.Common.dll 和 Microsoft.Practices.EnterpriseLibrary.Logging.dll 并使用 GACUTIL 注册它们,所以现在服务器包含以下二进制文件是广汽。

    PS > .\gacutil -l Microsoft.Practices.E
nterpriseLibrary.Common
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

The Global Assembly Cache contains the following assemblies:
  Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, proce
ssorArchitecture=MSIL
  Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, pro
cessorArchitecture=MSIL

Number of items = 2

PS > .\gacutil -l  Microsoft.Practices.
EnterpriseLibrary.Logging
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

The Global Assembly Cache contains the following assemblies:
  Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, proc
essorArchitecture=MSIL
  Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, pr
ocessorArchitecture=MSIL

Number of items = 2

我在网上找到的另一个参考资料如下所列,但它并没有教我如何解决这个问题。 ESB Toolkit 2.1 搞砸了 Enterprise Library 5.0

我什至向微软发布了一个后续问题。 ESB Toolkit 2.1 和独立企业库 5.0 应用程序配置问题

4

1 回答 1

0

我解决了。我对我的配置进行了以下更改,现在 Web 服务正在运行。

      <configSections>
     <section name="enterpriseLibrary.ConfigurationSource.SomeThingElse" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
  </configSections>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Practices.EnterpriseLibrary.Common" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="4.1.0.0" newVersion="5.0.505.0" />
        <publisherPolicy apply="no" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Practices.EnterpriseLibrary.Logging" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="4.1.0.0" newVersion="5.0.505.0" />
        <publisherPolicy apply="no" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

  <enterpriseLibrary.ConfigurationSource selectedSource="Local Application Configuration Source">
    <sources>
      <add name="Local Application Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" filePath="C:\inetpub\SomeThingElse\WebEntLib.config" />
    </sources>
    <redirectSections>
      <add sourceName="Local Application Configuration Source" name="loggingConfiguration" />
    </redirectSections>
  </enterpriseLibrary.ConfigurationSource>

重定向工作在我错的地方是将“enterpriseLibrary.ConfigurationSource”XML 标记重命名为“enterpriseLibrary.ConfigurationSource.SomeThingElse”

一旦我删除了 SomeThingElse,它现在就可以正常工作了。

在我采用这个解决方案之前,我还阅读了

跨多个应用程序共享配置部分

于 2016-08-23T03:14:40.763 回答