null指针为雅虎openid请求,但不是谷歌(dotnetopenid)

时间:2009-12-08 04:03:22

标签: c# dotnetopenauth

我正在以编程方式与雅虎和谷歌进行openid握手。谷歌很好,但雅虎抛出一个空指针:

堆栈跟踪:

   System.NullReferenceException: Object reference not set to an instance of an object.
   at DotNetOpenAuth.OpenId.Extensions.ProviderAuthenticationPolicy.PolicyResponse.DotNetOpenAuth.Messaging.IMessageWithEvents.OnReceiving() in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\OpenId\Extensions\ProviderAuthenticationPolicy\PolicyResponse.cs:line 189
   at DotNetOpenAuth.OpenId.ChannelElements.ExtensionsBindingElement.<GetExtensions>d__a.MoveNext() in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\OpenId\ChannelElements\ExtensionsBindingElement.cs:line 209
   at DotNetOpenAuth.OpenId.ChannelElements.ExtensionsBindingElement.ProcessIncomingMessage(IProtocolMessage message) in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\OpenId\ChannelElements\ExtensionsBindingElement.cs:line 151
   at DotNetOpenAuth.Messaging.Channel.ProcessIncomingMessage(IProtocolMessage message) in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\Messaging\Channel.cs:line 906
   at DotNetOpenAuth.OpenId.ChannelElements.OpenIdChannel.ProcessIncomingMessage(IProtocolMessage message) in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\OpenId\ChannelElements\OpenIdChannel.cs:line 171
   at DotNetOpenAuth.Messaging.Channel.ReadFromRequest(HttpRequestInfo httpRequest) in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\Messaging\Channel.cs:line 377
   at DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.GetResponse(HttpRequestInfo httpRequestInfo) in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\OpenId\RelyingParty\OpenIdRelyingParty.cs:line 489
   at DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.GetResponse() in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\OpenId\RelyingParty\OpenIdRelyingParty.cs:line 478
   at Friendsell.UI.Controllers.Auth.OpenIdReturnController.DoProcessRequest(IExecutionContext context) in C:\Development\Friendsell\Friendsell.UI\Controllers\Auth\OpenIdController.cs:line 41
   at Bistro.Controllers.AbstractController.ProcessRequest(HttpContextBase context, IContext requestContext) in C:\Development\Bistro\Bistro.Core\Controllers\AbstractController.cs:line 41
   at Bistro.Controllers.MethodDispatcher.InvokeMethodDirect(HttpContextBase context, String requestPoint, IContext requestContext) in C:\Development\Bistro\Bistro.Core\Controllers\MethodDispatcher.cs:line 221
   at Bistro.Controllers.MethodDispatcher.InvokeMethod(HttpContextBase context, String requestPoint, IContext requestContext) in C:\Development\Bistro\Bistro.Core\Controllers\MethodDispatcher.cs:line 119

调用代码:

        var openid = new OpenIdRelyingParty();
        IAuthenticationRequest request = openid.CreateRequest(
            Identifier.Parse(
                GetEndpoint()),
                new Realm(realm),
                new Uri(returnUri));

        // Require some additional data
        request.AddExtension(new ClaimsRequest
        {
            Email = DemandLevel.Require,
            FullName = DemandLevel.Request,
            PostalCode = DemandLevel.Request
        });

        try
        {
            request.RedirectToProvider();
        } catch (ThreadAbortException)
        {
        }

接收代码(以及异常的来源)

        var openId = new OpenIdRelyingParty();
        var response = openId.GetResponse(); <-- exception happens here

是什么给出的?奇怪的是,雅虎片最近才开始工作,我还没有改变库版本......

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)

我想你想看看你的CreateRequest。你也无法捕获ThreadAbortException,它会自我传播。因此你需要抓住它两次。