2012-04-17 12 views
3

を使用しながら、ウィジングズのAPIに接続したいと考えました。私は彼が完璧に働いた他のプロジェクトで同じコントローラを使用しました。サイトがAzure webrole(どのように問題であるかわからないプロジェクト)では、それはうまく動作しません。最初に取得しましたのレポートとログのエラーDotnetopenAuth

'DotNetOpenAuth.Reporting'の型初期化器が例外をスローしました。

は、だから私は、web.configファイルに

それをオフに

= "false" を有効に報告は今、私は

に「DotNetOpenAuthのタイプ初期化子を得ました。 Logger 'は例外を投げた。

私はlog4netのを使用しないでください。

public ActionResult StartOAuth() 
    { 

     var serviceProvider = GetServiceDescription(); 
     var consumer = new WebConsumer(serviceProvider, _tokenManager); 

     // Url to redirect to 
     var authUrl = new Uri(Request.Url.Scheme + "://" + Request.Url.Authority + "/Withings/OAuthCallBack"); 

     // request access 
     consumer.Channel.Send(consumer.PrepareRequestUserAuthorization(authUrl, null, null)); 

     // This will not get hit! 
     return null; 
    } 

private ServiceProviderDescription GetServiceDescription() 
    { 
     return new ServiceProviderDescription 
     { 
      AccessTokenEndpoint = new MessageReceivingEndpoint("https://oauth.withings.com/account/access_token", HttpDeliveryMethods.PostRequest), 
      RequestTokenEndpoint = new MessageReceivingEndpoint("https://oauth.withings.com/account/request_token", HttpDeliveryMethods.PostRequest), 
      UserAuthorizationEndpoint = new MessageReceivingEndpoint("https://oauth.withings.com/account/authorize", HttpDeliveryMethods.PostRequest), 
      TamperProtectionElements = new ITamperProtectionChannelBindingElement[] { new HmacSha1SigningBindingElement() }, 
      ProtocolVersion = ProtocolVersion.V10a 
     }; 
    } 

答えて

7

だから、それはアズールのせいだった。 web.configでDotnetOpenAuthを破ったセクションがあります。このセクションを削除するのが回避策です。おそらくlog4netのを追加することも、この問題を解決するだろうが、私はテストしていません。

<trace> 
<listeners> 
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics"> 

<filter type="" /> 
</add> 
</listeners> 
</trace> 
+0

うわー。共有してくれてありがとう。エラーの再現を試みて、例外の詳細をキャプチャして、何が間違っていたのかを知ることができれば(あなたはInnerExceptionを調べなければならないかもしれません)、私はあなたの発見を聞くことに最も興味があります。 –

+0

内部例外は{ "Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener、Microsoft.WindowsAzure.Diagnosticsを作成できませんでした= 1.0.0.0、文化= PublicKeyTokenニュートラル= 31bf3856ad364e35版。"} 'は' –

関連する問題