2014-06-06 91 views
0

我從2.0目前的ASP.NET應用程序遷移到4.0,並且還試圖將企業庫5.0 4.0Microsoft.Practices.ServiceLocation.ActivationException是由用戶代碼未處理

遷移我已經做了一切工作配置文件中的必要更改。所有的應用程序都在項目配合機器上工作,但它不適用於我的機器。

我收到錯誤的堆棧跟蹤---

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.WebUI\AppCode\LogEntryHelper.cs:line 252 
     at App.LogEntryHelper.WriteFacadePerformanceLog(DateTime start, DateTime end) in c:\App.Client.WebUI\AppCode\LogEntryHelper.cs:line 209 
     at App.Facade.FutureEventFacade.GetFutureEventsParticipant(Int64 participantID) in c:\App.Client.WebUI\Facade\FutureEventFacade.cs:line 92 
     at App.Facade.ParticipantFacade.GetParticipant(Int64 participantID) in c:\App.Client.WebUI\Facade\ParticipantFacade.cs:line 81 
     at App.ParticipantPage.Page_Load(Object sender, EventArgs e) in c:\App.Client.WebUI\ParticipantPage.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> 
+0

這與您提供的鏈接不同。 – user2407315

+0

你可以顯示你的unity.config文件嗎?它是否註冊了ent.library擴展名?我的意思是,明顯的異常與我提供的其他問題相同,但由於它在其他機器上工作 - 可能在GAC中缺少一些程序集註冊? – Alexander

+0

亞歷山大,我試圖檢查GAC組件並保持與其他工作機器完全相同的組件。 – user2407315

回答

1

我能夠解決問題的細節。我發現我安裝了導致問題的ESB 2.0版本。每當應用程序嘗試記錄IIS用於查看ESB配置文件而不是web.config文件的內容時。只要我卸載ESB應用程序,一切都開始工作。

1

對我來說,我打開了另一個配置文件,其中有企業庫,但它從本地應用程序配置文件中丟失。我在本地配置中添加了以下內容,並且通過了該錯誤。

<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> 
相關問題