在单声道下运行DotNetOpenAuth时,Logger.Create中的TypeLoadException

cap*_*gon 0 dotnetopenauth

我正在关注DotNetOpenAuth的简单教程.当我在localhost visual studio开发机器上运行它时它工作正常.

但是,只要我将其移动到运行mono的测试/登台服务器,就会抛出以下错误:

位置:Page_Load

 An exception was thrown by the type initializer for DotNetOpenAuth.Reporting
InnerException: System.TypeInitializationException: An exception was thrown by the type initializer for DotNetOpenAuth.Logger ---> System.TypeLoadException: A type                             load exception has occurred.
  at DotNetOpenAuth.Logger.Create (System.String name) [0x00000] in <filename unknown>:0
  at DotNetOpenAuth.Logger.CreateWithBanner (System.String name) [0x00000] in <filename unknown>:0
  at DotNetOpenAuth.Logger..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at DotNetOpenAuth.Reporting.Initialize () [0x00000] in <filename unknown>:0
  at DotNetOpenAuth.Reporting.set_Enabled (Boolean value) [0x00000] in <filename unknown>:0
  at DotNetOpenAuth.Reporting..cctor () [0x00000] in <filename unknown>:0
StackTrace:   at DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty..ctor (ICryptoKeyStore cryptoKeyStore, INonceStore nonceStore) [0x00000] in <filename unknow                            n>:0
  at DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty..ctor (IOpenIdApplicationStore applicationStore) [0x00000] in <filename unknown>:0
  at DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty..ctor () [0x00000] in <filename unknown>:0
  at MyApp.Login_Google.Page_Load (System.Object sender, System.EventArgs e) [0x00000] in <filename unknown>:0 
Run Code Online (Sandbox Code Playgroud)

我的页面加载代码如下所示:

protected void Page_Load(object sender, EventArgs e)
{

    OpenIdRelyingParty openid = new OpenIdRelyingParty();
    var response = openid.GetResponse();
    if (response != null)
    {
        switch (response.Status)
        {
            case AuthenticationStatus.Authenticated:

                // This is where you would look for any OpenID extension responses included
                // in the authentication assertion.
                var claimsResponse = response.GetExtension<ClaimsResponse>();

                //Database.ProfileFields = claimsResponse;

                //// Store off the "friendly" username to display -- NOT for username lookup
                //Database.FriendlyLoginName = response.FriendlyIdentifierForDisplay;

                // Use FormsAuthentication to tell ASP.NET that the user is now logged in,
                // with the OpenID Claimed Identifier as their username.
                //FormsAuthentication.RedirectFromLoginPage(response.ClaimedIdentifier, false);


                break;
            case AuthenticationStatus.Canceled:
                //this.loginCanceledLabel.Visible = true;
                break;
            case AuthenticationStatus.Failed:
                //this.loginFailedLabel.Visible = true;
                break;
        }
    }

}
Run Code Online (Sandbox Code Playgroud)

这是导致错误的行:

OpenIdRelyingParty openid = new OpenIdRelyingParty();
Run Code Online (Sandbox Code Playgroud)

单声道版本:

Mono JIT compiler version 2.10.5 (Debian 2.10.5-1)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  x86
        Disabled:      none
        Misc:          softdebug
        LLVM:          supported, not enabled.
        GC:            Included Boehm (with typed GC and Parallel Mark)
Run Code Online (Sandbox Code Playgroud)

Eri*_*oom 5

我通过简单地将log4net DLL添加到项目目录解决了这个问题,一切正常.