調用存儲方法時,我使用溫莎城堡v3.4.0創建RavenDB文件會話實例,但是當我後來使用RavenDB客戶端版本低於3.0.3660我得到這個錯誤最小的代碼我可以拿出,再現錯誤:如何使用Castle Windsor創建客戶端版本> 3.0.3660的RavenDB會話?</p> <pre><code>Castle.MicroKernel.ComponentNotFoundException: 'No component for supporting the service System.Net.Http.HttpMessageHandler was found' </code></pre> <p>這裏是:
using Castle.Facilities.TypedFactory;
using Castle.MicroKernel.Registration;
using Castle.Windsor;
using Raven.Client;
using Raven.Client.Document;
public class Program
{
public static void Main()
{
var container = new WindsorContainer();
container.AddFacility<TypedFactoryFacility>();
container.Register(
Component
.For<IDocumentStore>()
.ImplementedBy<DocumentStore>()
.DependsOn(new { Url = "http://localhost:8081", DefaultDatabase = "Test" })
.OnCreate(x => x.Initialize())
.LifeStyle.Singleton,
Component
.For<IDocumentSession>()
.UsingFactoryMethod(x => x.Resolve<IDocumentStore>().OpenSession())
.LifeStyle.Transient);
using (var documentSession = container.Resolve<IDocumentSession>())
{
documentSession.Store(new object());
documentSession.SaveChanges();
}
}
}
這是我相信正在發生的事情。更改了v3.0.3660改變了HttpMessageHandler如何在HttpJsonRequest類創建後的RavenDB客戶端進行:
https://github.com/ravendb/ravendb/commit/740ad10d42d50b1eff0fc89d1a6894fd57578984
我相信這個變化,結合我在我的溫莎容器使用TypedFactoryFacility的導致RavenDB請求HttpJsonRequestFactory的一個實例,並且它是來自Windsor的依賴關係,而不是使用它自己的內部實例。
如何更改我的代碼以避免此問題,以便我可以使用更新版本的RavenDB客戶端?