2015-01-07 105 views
4

我剛剛克隆一個項目,一個新的機器,我得到一個難以調試NullReferenceException在MVC本站OWIN:的NullReferenceException與Owin

[NullReferenceException: Object reference not set to an instance of an object.] 
    Microsoft.Owin.Security.Cookies.<AuthenticateCoreAsync>d__0.MoveNext() +664 
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93 
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52 
    System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +24 
    Microsoft.Owin.Security.Infrastructure.<BaseInitializeAsync>d__2.MoveNext() +860 
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93 
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52 
    System.Runtime.CompilerServices.TaskAwaiter.GetResult() +21 
    Microsoft.Owin.Security.Infrastructure.<Invoke>d__0.MoveNext() +427 
    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +22 
    Microsoft.Owin.Host.SystemWeb.Infrastructure.ErrorState.Rethrow() +33 
    Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult ar) +150 
    Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult ar) +42 
    System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +415 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155 

它發生後

[assembly: OwinStartupAttribute(typeof(Website.Startup))] 
namespace Website 
{ 
    public partial class Startup 
    { 
     public void Configuration(IAppBuilder app) 
     { 
      ConfigureAuth(app); 
     } 
    } 
} 

但是,就像我在F10ing拋出異常之後所看到的一樣 - 它永遠不會到達第一個控制器的構造函數。

有沒有人以前經歷過這個和/或可以指出我的方向可能是錯誤的原因?

回答

5

將OWIN從v2更新到v3似乎解決了這個問題。

值得注意的是,所有OWIN相關的軟件包也應該更新。

8

上面的解決方案並沒有幫助我,但我終於在嘗試了很多事情後找到了答案。

我同時開發了多個解決方案,並且本地主機cookie中的某些事情一定會糾結(每個解決方案都運行在不同的本地主機端口上)。清除我的本地主機cookies後,問題已解決。

+1

我之前就有過它,之前解決過它,並沒有記住......謝謝你的回答,這是愚蠢的伎倆:)。 –

0

從OWIN v3.0更新到v3.1爲我解決了這個問題。