2013-03-10 27 views
0

我試着用AutoFac(從here採取和here樣品)以下:如何使用AutoFac註冊此.NET接口?

builder.Register(c => c.Resolve<IDocumentStore>().OpenSession())   
     .InstancePerLifetimeScope(); 

的問題是,與AutoFac的當前版本中,我得到c.Resolve

編譯誤差有人請告訴我如何註冊一個IDocumentSession,這是給我的IDocumentStore實例OpenSession()方法。

enter image description here

+2

這個問題就是要做有R#,刪除R·緩存和重新開放的解決方案。如果您遇到過這個問題,並且項目建立良好,但無論如何都會收到警告,R#問題。 – Phill 2013-03-10 05:41:59

回答

2
builder.RegisterInstance(documentStore).As<IDocumentStore>(); 

builder.Register(x => x.Resolve<IDocumentStore>().OpenSession()) 
     .As<IDocumentSession>() 
     .InstancePerLifetimeScope();