0

I am using NHibernate 3.3 with vb.net I am trying to mapping through code but it results in cannot create an instance of interface. Code is as below.

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()

error occurs at IproxyFactoryFactory. I included all required references such as NHibernate.Linq, NHibernate.dialect etc Please help Thanks

Muhammad Ali Hassan
  • 960
  • 2
  • 12
  • 29

1 Answers1

0

The line:

cfg.Properties.Add(NHibernate.Cfg.Environment. _
              ProxyFactoryFactoryClass, GetType _
              (NHibernate.Bytecode.IProxyFactoryFactory). _
              AssemblyQualifiedName)

The ProxyFactoryFactoryClass is meant to be a class, but you are specifying an interface (NHibernate.Bytecode.IProxyFactoryFactory), change it to:

cfg.Properties.Add(NHibernate.Cfg.Environment. _
              ProxyFactoryFactoryClass, GetType _
              (NHibernate.Bytecode.DefaultProxyFactoryFactory). _
              AssemblyQualifiedName)
Martin Ernst
  • 5,629
  • 2
  • 17
  • 14