Microsoft.Practices.ServiceLocation.ActivationException未被用户代



我正在迁移当前的ASP。. NET应用程序从2.0迁移到4.0,并尝试将企业库从4.0迁移到5.0

我已经在配置文件中做了所有必要的更改。所有的应用程序都在项目伙伴的机器上工作,但它不能在我的机器上工作。我得到的错误的跟踪——
Microsoft.Practices.ServiceLocation.ActivationException was unhandled by user code
  HResult=-2146233088
  Message=Activation error occured while trying to get instance of type LogWriter, key ""
  Source=Microsoft.Practices.ServiceLocation
  StackTrace:
       at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
       at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService]()
       at Microsoft.Practices.EnterpriseLibrary.Logging.Logger.get_Writer()
       at Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(LogEntry log)
       at App.LogEntryHelper.WriteLogEntry(LogEntry entry, String category) in c:App.Client.WebUIAppCodeLogEntryHelper.cs:line 252
       at App.LogEntryHelper.WriteFacadePerformanceLog(DateTime start, DateTime end) in c:App.Client.WebUIAppCodeLogEntryHelper.cs:line 209
       at App.Facade.FutureEventFacade.GetFutureEventsParticipant(Int64 participantID) in c:App.Client.WebUIFacadeFutureEventFacade.cs:line 92
       at App.Facade.ParticipantFacade.GetParticipant(Int64 participantID) in c:App.Client.WebUIFacadeParticipantFacade.cs:line 81
       at App.ParticipantPage.Page_Load(Object sender, EventArgs e) in c:App.Client.WebUIParticipantPage.aspx.cs:line 67
       at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
       at System.Web.UI.Control.OnLoad(EventArgs e)
       at System.Web.UI.Adapters.ControlAdapter.OnLoad(EventArgs e)
       at System.Web.UI.Control.LoadRecursive()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  InnerException: Microsoft.Practices.Unity.ResolutionFailedException
       HResult=-2146233088
       Message=Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The type LogWriter cannot be constructed. You must configure the container to supply this value.
-----------------------------------------------
At the time of the exception, the container was:
  Resolving Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter,(none)
       Source=Microsoft.Practices.Unity
       TypeRequested=LogWriter
       StackTrace:
            at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
            at Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides)
            at Microsoft.Practices.Unity.UnityServiceLocator.DoGetInstance(Type serviceType, String key)
            at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
       InnerException: System.InvalidOperationException
            HResult=-2146233079
            Message=The type LogWriter cannot be constructed. You must configure the container to supply this value.
            Source=Microsoft.Practices.Unity
            StackTrace:
                 at Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.GuardTypeIsNonPrimitive(IBuilderContext context, SelectedConstructor selectedConstructor)
                 at Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.PreBuildUp(IBuilderContext context)
                 at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
                 at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlanCreatorPolicy.CreatePlan(IBuilderContext context, NamedTypeBuildKey buildKey)
                 at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
                 at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
                 at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
            InnerException: 

下面是配置文件

的细节
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
  <configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <section name="App.Properties.SecuritySettings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
      <section name="App.Properties.ReportingSettings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
      <section name="App.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
    </sectionGroup>
    <sectionGroup name="system.web">
      <section name="uploadManagement" type="App.WebControls.UploadModule, App.WebControls"/>
    </sectionGroup>
    <!-- AJAX -->
    <!-- End AJAX -->
  </configSections>
  <loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="" logWarningsWhenNoCategoriesMatch="true">
    <listeners>
      <add fileName="App.Debug.log" header="----------------------------------------" footer="----------------------------------------" formatter="Text Formatter" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Debug Flat File TraceListener"/>
      <add fileName="App.Client.WebUI.Facade.Performance.log" header="----------------------------------------" footer="----------------------------------------" formatter="Text Formatter" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Facade Performance Flat File TraceListener"/>
      <add fileName="App.Exception.log" rollSizeKB="10000" timeStampPattern="ddd" rollFileExistsBehavior="Overwrite" rollInterval="Day" formatter="Text Formatter" header="----------------------------------------" footer="----------------------------------------" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" traceOutputOptions="Callstack" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Rolling Flat File TraceListener"/>
      <add source="AdminTool Web UI" formatter="Text Formatter" log="AdminTool" machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" traceOutputOptions="Callstack" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="WebUI EventLog TraceListener"/>
      <add fileName="App.SSO.log" header="----------------------------------------" footer="----------------------------------------" formatter="Text Formatter" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="SSO Flat File TraceListener"/>
    </listeners>
    <formatters>
      <add template="Timestamp: {timestamp}&#xA;Message: {message}&#xA;Category: {category}&#xA;Priority: {priority}&#xA;EventId: {eventid}&#xA;Severity: {severity}&#xA;Title:{title}&#xA;Machine: {machine}&#xA;Application Domain: {appDomain}&#xA;Process Id: {processId}&#xA;Process Name: {processName}&#xA;Win32 Thread Id: {win32ThreadId}&#xA;Thread Name: {threadName}&#xA;Extended Properties: {dictionary({key} - {value}&#xA;&#xA;)}" type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Text Formatter"/>
    </formatters>
    <logFilters>
      <add minimumPriority="0" maximumPriority="3" type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.PriorityFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Priority Debug Filter"/>
    </logFilters>
    <categorySources>
      <add switchValue="All" name="Web UI Debug">
        <listeners>
          <add name="Debug Flat File TraceListener"/>
        </listeners>
      </add>
      <add switchValue="All" name="Web UI Exception">
        <listeners>
          <add name="Rolling Flat File TraceListener"/>
          <add name="WebUI EventLog TraceListener"/>
        </listeners>
      </add>
      <add switchValue="All" name="Web UI Facade Performance">
        <listeners>
          <add name="Facade Performance Flat File TraceListener"/>
        </listeners>
      </add>
      <add switchValue="All" name="Web UI SSO">
        <listeners>
          <add name="SSO Flat File TraceListener"/>
        </listeners>
      </add>
    </categorySources>
    <specialSources>
      <allEvents switchValue="All" name="All Events"/>
      <notProcessed switchValue="All" name="Unprocessed Category">
        <listeners>
          <add name="Debug Flat File TraceListener"/>
          <add name="WebUI EventLog TraceListener"/>
          <add name="SSO Flat File TraceListener"/>
        </listeners>
      </notProcessed>
      <errors switchValue="All" name="Logging Errors &amp; Warnings"/>
    </specialSources>
  </loggingConfiguration>
  <exceptionHandling>
    <exceptionPolicies>
      <add name="WebUI Policy">
        <exceptionTypes>
          <add type="System.DirectoryServices.DirectoryServicesCOMException, System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" postHandlingAction="None" name="DirectoryServicesCOMException"/>
          <add type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="None" name="Exception">
            <exceptionHandlers>
              <add logCategory="Web UI Exception" eventId="2000" severity="Error" title="Enterprise Library Exception Handling" formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" priority="0" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Logging Handler"/>
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
    </exceptionPolicies>
  </exceptionHandling>
</configuration>

我能解决这个问题。我发现我安装的ESB 2.0版本导致了这个问题。每当应用程序试图记录某些内容时,IIS就会查看ESB配置文件,而不是web。配置文件。一旦我卸载了ESB应用程序,一切就开始工作了。

对我来说,我正在打开另一个配置文件,该文件具有enterpriseLibrary,但它从本地应用程序配置文件中缺失。我在本地配置中添加了以下内容,并解决了错误。

  <configSections>
       <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral" requirePermission="true" />
 </configSections>

相关内容

  • 没有找到相关文章

最新更新