调用存储方法时,我使用温莎城堡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客户端?