2013-12-19 272 views
0

我正在使用NHibernate 3.3與vb.net 我試圖通過代碼映射,但它導致無法創建接口的實例。代碼如下。Nhibernate映射

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

行:

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)