Extract the binaries to your "lib" directory relative to your source files
Open a command prompt and navigate the to "bin" directory in your web project.
Enter the following command: ..\..\..\lib\bin\net-2.0\NHPG.exe /o:Example.Domain.Proxies.dll Example.Domain.dll
NHPG.exe: The console application that generates the proxies. Included in the binary distribution from step 1 /o: The path to the assembly that will be generated by NHPG Example.Domain.dll: The assembly that contains your NHibernate Mappings (hbm.xml files)
Add 'proxyfactory.factory_class' to your NHibernate configuration file: <hibernate-configurationxmlns="urn:nhibernate-configuration-2.2"> <session-factory> <propertyname="dialect">NHibernate.Dialect.MsSql2000Dialect</property> <propertyname="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> <propertyname="connection.driver_class">NHibernate.Driver.SqlClientDriver</property> <propertyname="connection.connection_string">Server=(local);Database=Development;Trusted_Connection=True;</property> <mappingassembly="Example.Domain"/>
<propertyname="proxyfactory.factory_class">CastleStaticProxyFactoryFactory, Example.Domain.Proxies</property> </session-factory> </hibernate-configuration> Replace Example.Domain.Proxies with the name of the assembly used for argument '/o' in Step 4.
You're done! Pre-generated lazy loading proxies can be used with NHibernate to Run in Medium Trust
Sample Commands
Generate proxies for ActiveRecord NHPG.exe /g:activerecord /o:Example.ActiceRecordDomain.Proxies.dll Example.ActiveRecordDomain.dll
Generate proxies with multiple class mapping assemblies NHPG.exe /o:Example.Domain.Proxies.dll Example.Domain1.dllExample.Domain2.dll
Generate proxies with a custom Dialect NHPG.exe /d:NHibernate.Dialect.Oracle9Dialect /o:Example.Domain.Proxies.dll Example.Domain.dll