我正在使用NHibernate 3.3和vb.net 我试图通过代码映射,但它导致无法创建接口的实例。 代码如下。
Dim cfg As New Configuration()
cfg.Properties.Add(NHibernate.Cfg.Environment. _
ConnectionProvider, GetType(NHibernate.Connection. _
DriverConnectionProvider).AssemblyQualifiedName)
cfg.Properties.Add(NHibernate.Cfg.Environment.Dialect, _
GetType(NHibernate.Dialect.MsSql2008Dialect). _
AssemblyQualifiedName)
cfg.Properties.Add(NHibernate.Cfg.Environment.ConnectionDriver, _
GetType(NHibernate.Driver.SqlClientDriver). _
AssemblyQualifiedName)
cfg.Properties.Add(NHibernate.Cfg.Environment.ConnectionStringName, _
"myconnectionstring")
cfg.Properties.Add(NHibernate.Cfg.Environment. _
ProxyFactoryFactoryClass, GetType _
(NHibernate.Bytecode.IProxyFactoryFactory). _
AssemblyQualifiedName)
Dim s2 As NHibernate.ISessionFactory = cfg.BuildSessionFactory
db = s2.OpenSession()
IproxyFactoryFactory发生错误。 我包括所有必需的引用,如NHibernate.Linq,NHibernate.dialect等 请帮忙 感谢
答案 0 :(得分:0)
该行:
cfg.Properties.Add(NHibernate.Cfg.Environment. _
ProxyFactoryFactoryClass, GetType _
(NHibernate.Bytecode.IProxyFactoryFactory). _
AssemblyQualifiedName)
ProxyFactoryFactoryClass是一个类,但是您指定了一个接口(NHibernate.Bytecode.IProxyFactoryFactory),将其更改为:
cfg.Properties.Add(NHibernate.Cfg.Environment. _
ProxyFactoryFactoryClass, GetType _
(NHibernate.Bytecode.DefaultProxyFactoryFactory). _
AssemblyQualifiedName)