我正在关注一个简单的tutorial on 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
我的页面加载代码如下所示:
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;
}
}
}
这是导致错误的行:
OpenIdRelyingParty openid = new OpenIdRelyingParty();
单声道版本:
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)
答案 0 :(得分:5)
我通过简单地将log4net DLL添加到项目目录中解决了这个问题,一切正常。
答案 1 :(得分:2)
看起来像单声道加载程序集的区别,抛出不同于Microsoft的CLR的异常。我已提交issue #151来跟踪此事。
在此期间,请尝试下载this patched build,这是v4.0.3,其中包含针对此错误的建议修复程序,并查看它是否适合您。
这假设正常构建在单声道上工作。