问题
I am attempting to get nhibernate working in medium-trust. What I found said that I needed to use a proxy generator. I pulled the one from nhibernate's site. When I attempt to use it, I recieve an error that it could not load the assembly 'DynamicProxyGenAssembly2'. Is there something I am missing or is there one that works somewhere. I would prefer not to use the generator, but there seems to be no alternative with nhibernate.
回答1:
From what I gather the issue with medium trust is the use of reflection being nerfed some what (though I could be completely off here).
It also seems that your approach of physically pre-building the proxy objects seems to be the suggested one and this link may help.
To be honest I had a similar issue with shared hosting and decided to opt for using a a hosting provider that offered virtual server. This obviously removes the medium trust issue as it's like having a cheap and nasty dedicated server at your disposal.
I know that this answer may not have been the best, but I do feel your pain and wanted to chime up a little. Also, its worth mentioning that the best place to get NHibernate related questions answered is their forums (http://forum.hibernate.org).
回答2:
Thad I know this question is old, but I just wanted to tell you and others with this issue that it is really pretty easy to run NHibernate in a medium trust environment once you know what to do. All you have to do is to do the following:
- Rebuild Castle from source and get the dlls from that
- Rebuild NHibernate from source using the dlls from the prior step and get the dlls
- Add the dlls to your project.
You need to pay attention to the versions of Castle and NHibernate to make sure that they will work together, but you don't have to disable lazy loading or do anything else. Here is a blog post about it that outlines how you can easily set up your project in a medium trust environment: How To Run NHibernate In A Medium Trust Environment
来源:https://stackoverflow.com/questions/608492/nhibernate-proxy-generator