问题
This issue is similar with the one raised here in stack overflow ESB Toolkit and Enterprise Library collision
I have tried the suggested resolution but still couldn't get my web service to work.
Does anyone have answers for this, I have a similar problem. The Biztalk ESB has been installed and it breaks my web.config.
This is what my web.config looks like
<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>
And this is what my webEntLib.config looks like.
<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 & Warnings">
<listeners>
<add name="Rolling Flat File Trace Listener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>
I even tried your suggestion of putting in a redirect at both the web.config and the 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>
The Microsoft article about dll redirect is at the following link Redirecting Assembly Versions
But it dosent seem to work. What am I doing wrong or what else can I do?
I have even added a dedicated Microsoft.Practices.EnterpriseLibrary.Common.dll and the Microsoft.Practices.EnterpriseLibrary.Logging.dll into the bin folder of the web site and have used GACUTIL to register them so now the server contains the following binaries in it's GAC.
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
One other reference I found on the net is as listed below, but it dosent teach me how to resolve the issue. ESB Toolkit 2.1 mess up Enterprise Library 5.0 big time
I have even posted a followup question to Microsoft. ESB Toolkit 2.1 and Stand Alone Enterprise Library 5.0 Application Configuration Issue
回答1:
I solved it. I made the following changes to my configuration and the web service is now working.
<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>
The redirection worked where I was wrong is to rename the "enterpriseLibrary.ConfigurationSource" XML tag to "enterpriseLibrary.ConfigurationSource.SomeThingElse"
once I have removed the SomeThingElse, it is fully working now.
Before I resort to this solution I also had a read up at
Sharing Configuration Sections across Multiple Applications
来源:https://stackoverflow.com/questions/39090193/esb-toolkit-and-enterprise-library-collision-with-iis-web-config