简体   繁体   English

C#Microsoft.Practices.EnterpriseLibrary.Logging错误

[英]C# Microsoft.Practices.EnterpriseLibrary.Logging error

I am getting an error when i tried to used Microsoft.Practices.EnterpriseLibrary.Logging 我尝试使用Microsoft.Practices.EnterpriseLibrary.Logging时收到错误

The type initializer for 'Microsoft.Practices.EnterpriseLibrary.Logging.Logger' threw an exception. “Microsoft.Practices.EnterpriseLibrary.Logging.Logger”的类型初始值设定项引发了异常。

<configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null" />
  </configSections>
  <loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="Tracing" logWarningsWhenNoCategoriesMatch="true">
    <listeners>
      <add fileName="F:\Service\Service\log\Full\Service.log" rollSizeKB="1024" timeStampPattern="yyyy-MM-dd" rollFileExistsBehavior="Increment" rollInterval="None" formatter="Text Formatter" header="" footer="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null" traceOutputOptions="LogicalOperationStack" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null" name="AppLog" />
     </listeners>
    <formatters>
      <add template="{timestamp} : {message}" type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null" name="Text Formatter" />
    </formatters>
    <categorySources>
      <add switchValue="All" name="AppLog">
        <listeners>
          <add name="AppLog" />
        </listeners>
      </add>
      <add switchValue="Verbose" name="ExceptionHandling">
        <listeners>
          <add name="Exception" />
        </listeners>
      </add>
      <add switchValue="Information" name="Tracing">
        <listeners>
          <add name="Trace" />
        </listeners>
      </add>
    </categorySources>
    <specialSources>
      <allEvents switchValue="All" name="All Events" />
      <notProcessed switchValue="All" name="Unprocessed Category" />
      <errors switchValue="Off" name="Logging Errors  Warnings" />
    </specialSources>
  </loggingConfiguration>

Any help will be appreciated 任何帮助将不胜感激

Thanks 谢谢

k ķ

I faced this issue and after spending long time, if found that in my configuration, declaration of "configSection" should be first tag. 我遇到了这个问题并且花了很长时间后,如果发现在我的配置中,“configSection”的声明应该是第一个标签。 If there is any other tag before it then it throws same error. 如果之前有任何其他标记,那么它会抛出相同的错误。

In my case, there was target framework tag before my configsection. 就我而言,在我的配置部分之前有目标框架标签。 I moved it to after that and it starts working 我把它移到那之后就开始工作了

暂无
暂无

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

相关问题 C#无法加载文件或程序集&#39;Microsoft.Practices.EnterpriseLibrary.Logging - C# Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging 无法加载文件或程序集&#39;Microsoft.Practices.EnterpriseLibrary.Logging - Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging 使用 Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener 在 C# app.config 中的文件名中附加日期 - appending date in filename in C# app.config using Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener EnterpriseLibrary 6错误:无法访问已处置的对象(对象名称:&#39;Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter&#39;) - EnterpriseLibrary 6 error: Cannot access a disposed object (Object name: 'Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter') Microsoft.Practices.EnterpriseLibrary.* 的替代品 - Alternatives to Microsoft.Practices.EnterpriseLibrary.* 为什么GETDATE()在SSMS和C#Microsoft.Practices.EnterpriseLibrary.Data上运行时会产生不同的结果? - Why do GETDATE() yield different result when run on SSMS vs. C# Microsoft.Practices.EnterpriseLibrary.Data? 什么是 Microsoft.Practices.EnterpriseLibrary.Data - what is Microsoft.Practices.EnterpriseLibrary.Data 使用 UNC 路径运行 exe 时,Microsoft.Practices.EnterpriseLibrary 出现部分受信任的调用者错误? - Getting partially trusted callers error with Microsoft.Practices.EnterpriseLibrary when run exe using UNC path? 错误:“ Microsoft.Practices.EnterpriseLibrary.Data.Database.DbProviderFactory.get”:无法显式调用运算符或访问器 - Error: 'Microsoft.Practices.EnterpriseLibrary.Data.Database.DbProviderFactory.get': cannot explicitly call operator or accessor 升级到EL 5&#39;Microsoft.Practices.EnterpriseLibrary.Caching ..或其依赖项之一时出错 - error while upgrading to EL 5 'Microsoft.Practices.EnterpriseLibrary.Caching ..or one of its dependencies
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM