TypeLoadException from Logger.Create when running DotNetOpenAuth under mono

六眼飞鱼酱① 提交于 2019-12-06 16:52:43

问题


I'm following a simple tutorial on DotNetOpenAuth. It works fine when i run it in my localhost visual studio development machine.

However, as soon as a I move it to a testing/staging server that is running mono it throws the following error:

Location: 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 

My Page load code looks like this:

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;
        }
    }

}

This is the line which causes the error:

OpenIdRelyingParty openid = new OpenIdRelyingParty();

Mono Version:

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)

回答1:


It looks like a difference in how mono loads assemblies, throwing different exceptions than Microsoft's CLR does. I've filed issue #151 to track this.

In the meantime, please try downloading this patched build, which is v4.0.3 with the proposed fix for this bug, and see if it works for you.

This assumes that otherwise, the normal builds work on mono.




回答2:


I solved this issue by simply adding the log4net DLL to the project directory and everything works.



来源:https://stackoverflow.com/questions/10805773/typeloadexception-from-logger-create-when-running-dotnetopenauth-under-mono

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!