2013-11-20 43 views
1

我有我的工作與引用log4netNinjectNinject.Extensions.LoggingNinject.Extensions.Logging.Log4net的應用程序。當我嘗試運行該應用程序時,我收到一個異常:使用Ninject.Extensions.Logging.Log4Net運行項目時,「繼承安全規則違反」?

{"Inheritance security rules violated by type: 'Ninject.Extensions.Logging.LoggerModuleBase'. Derived types must either match the security accessibility of the base type or be less accessible.":"Ninject.Extensions.Logging.LoggerModuleBase"} 

我完全不熟悉Ninject和日誌擴展。我見過severalsuggestions圍繞涉及添加類似:

[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)] 

但我看不到實際的問題是什麼,爲什麼我應該需要修改版本的源代碼與我的應用程序合併。因此,我假設我做錯了什麼。這個問題可能是什麼?

欲瞭解更多信息,該應用程序是針對.Net 4而不是.Net 4客戶端配置文件,我已經嘗試在構建擴展時同時針對客戶端配置文件和完整的.Net 4框架,但都沒有工作。

我使用提供的.sln文件(而不是nAnt構建文件)構建了擴展的發行版本。擴展項目可在Github上找到。

我在運行Visual Studio 2010

我的內核是建立像這樣:

private static StandardKernel kernel; 
public static StandardKernel Kernel 
{ 
    get 
    { 
     return kernel; 
    } 
} 

public static void BuildKernel() 
{ 
    var settings = new NinjectSettings 
    { 
     LoadExtensions = false 
    }; 

    var modules = new INinjectModule[] 
    { 
     new MainModule(), 
     new Log4NetModule() 
    }; 

    kernel = new StandardKernel(settings, modules); 
} 

我log4net的配置是相當基本的,但這裏是我的全部app.config文件:

<configuration> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <probing privatePath="lib" /> 
    </assemblyBinding> 
    </runtime> 
    <configSections> 
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/> 
    </configSections> 
    <log4net> 
    <appender name="BasicAppender" type="log4net.Appender.FileAppender"> 
     <threshold value="Warn"/> 
     <file value="Logs/errorlog.txt"/> 
     <appendToFile value="true" /> 
     <layout type="log4net.Layout.PatternLayout"> 
     <header value="[Basic Appender]&#13;&#10;" /> 
     <footer value="[Basic Appender]&#13;&#10;" /> 
     <conversionPattern value="%date [%thread] %-5level %logger [%ndc] &lt;%property{auth}&gt; - %message%newline" /> 
     </layout> 
    </appender> 
    <root> 
     <level value="ALL" /> 
     <appender-ref ref="BasicAppender" /> 
    </root> 
    </log4net> 
</configuration> 

回答

相關問題