开发者

NHibernate - missing dll's

This call

// this._cfg is an NHibernate Configuration instance

this._sessionFactory = this._cfg.BuildSessionFactory();

Gives me this exception at runtime (NOT at compile time).

Could not load file or assembly 'NHibernate.ByteCode.Castle' or one of its dependencies. The system cannot find the file specified.":"NHibernate.ByteCode.Castle

OK so far. But the thing is, this code is running in a class library project, and I have referenced NHibernate.ByteCode.Castle (along with all the other NHibernate dll's) in that project.

Wierder: I can fix the exception by additionally referencing the NHibernate dll's in the Windows WPF executable project that calls my class library. But the Window开发者_运维知识库s WPF executable contains no code that directly uses NHibernate (as evidenced by: It compiles fine without any NHibernate references). So what's going on? Apparently it's insufficient to reference NHibernate.ByteCode.Castle in the project that actually uses the NHibernate stuff. Anyone know why?


I know this is old, but what I've done to fix the dependency problem is simple:

In my UnitOfWork I added one static method:

private static void bringCastleDamnit()
{
   var pf = new NHibernate.ByteCode.Castle.ProxyFactoryFactory();
}

Then, and only then, would MSBuild see that it was needed and copy it to my output directory for my (asp.net and console) apps that references my Data project.


I wouldn't reference the castle byte code factory at all; just ensure it (and all other needed dependancies) are copied to the output directory using a post-build step.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜