城堡的ActiveRecord"无法编译的映射文件:(串)" [英] Castle ActiveRecord "Could not compile the mapping document: (string)"
问题描述
我有尝试初始化的ActiveRecord,我想不通,我缺少的是什么时,得到一个例外。我试图说服我工作用城堡ActiveRecord的公司,它也不会好看,如果我不能证明它是如何工作。我对项目的工作之前,与城堡ActiveRecord的,我以前从来没有遇到此问题。
感谢您的帮助
这是我得到的例外是
堆栈跟踪:
在Castle.ActiveRecord.ActiveRecordStarter.AddXmlString(配置配置,XML字符串,ActiveRecordModel模型) 在Castle.ActiveRecord.ActiveRecordStarter.AddXmlToNHibernateCfg(ISessionFactoryHolder持有人,ActiveRecordModelCollection型号) 在Castle.ActiveRecord.ActiveRecordStarter.RegisterTypes(ISessionFactoryHolder持有人,IConfigurationSource源,IEnumerable`1类型,布尔ignoreProblematicTypes) 在Castle.ActiveRecord.ActiveRecordStarter.Initialize(IConfigurationSource来源,类型[]类型) 在ConsoleApplication1.Program.Main(字串[] args)在C:\项目\ CastleDemo \ ConsoleApplication1 \的Program.cs:行20 在System.AppDomain._nExecuteAssembly(议会会议,字串[] args) 在System.AppDomain.ExecuteAssembly(字符串assemblyFile,证据assemblySecurity,字串[] args) 在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 在System.Threading.ThreadHelper.ThreadStart_Context(对象状态) 在System.Threading.ExecutionContext.Run(ExecutionContext中的ExecutionContext,ContextCallback回调,对象的状态) 在System.Threading.ThreadHelper.ThreadStart()
内部异常:
{无法编译的映射文件:(串)}
下面是我的配置文件:
<添加
关键=connection.driver_class
值=NHibernate.Driver.SqlClientDriver/>
<添加
关键=方言
值=NHibernate.Dialect.MsSql2000Dialect/>
<添加
关键=connection.provider
值=NHibernate.Connection.DriverConnectionProvider/>
<添加
关键=connection.connection_string
值=数据源= SPIROS \ SQLX;初始目录= CastleDemo;集成安全性= SSPI/>
<添加
关键=proxyfactory.factory_class
值=NHibernate.Byte code.Castle.ProxyFactoryFactory,NHibernate.Byte code.Castle/>
这是运行初始化的主要方法:
静态无效的主要(字串[] args)
{
//配置的ActiveRecord源
XmlConfigurationSource源=新XmlConfigurationSource(../../ config.xml文件);
//
// Initialazi的ActiveRecord
ActiveRecordStarter.Initialize(源的typeof(产品));
//
//创建模式
ActiveRecordStarter.CreateSchema();
//
}
行..得到它的工作。
一个NHibernate的,我有的版本需要有冬眠中的关键属性。
例如
取而代之的是
<添加
关键=connection.driver_class
值=NHibernate.Driver.SqlClientDriver/>
这样做:
<添加
关键=hibernate.connection.driver_class
值=NHibernate.Driver.SqlClientDriver/>
有关新版本的NHibernate的另一作品。
Hi I am having getting an exception when trying to initialize ActiveRecord and I cannot figure out what I am missing. I am trying to convince the company I work for to use Castle ActiveRecord and it won't look good if I can't demonstrate how it works. I have work on projects before with Castle ActiveRecord and I had never experience this problem before.
Thanks for your help
The exception that I get is
Stack Trace:
at Castle.ActiveRecord.ActiveRecordStarter.AddXmlString(Configuration config, String xml, ActiveRecordModel model) at Castle.ActiveRecord.ActiveRecordStarter.AddXmlToNHibernateCfg(ISessionFactoryHolder holder, ActiveRecordModelCollection models) at Castle.ActiveRecord.ActiveRecordStarter.RegisterTypes(ISessionFactoryHolder holder, IConfigurationSource source, IEnumerable`1 types, Boolean ignoreProblematicTypes) at Castle.ActiveRecord.ActiveRecordStarter.Initialize(IConfigurationSource source, Type[] types) at ConsoleApplication1.Program.Main(String[] args) in C:\Projects\CastleDemo\ConsoleApplication1\Program.cs:line 20 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
Inner Exception:
{"Could not compile the mapping document: (string)"}
Below is my configuration file:
<add
key="connection.driver_class"
value="NHibernate.Driver.SqlClientDriver" />
<add
key="dialect"
value="NHibernate.Dialect.MsSql2000Dialect" />
<add
key="connection.provider"
value="NHibernate.Connection.DriverConnectionProvider" />
<add
key="connection.connection_string"
value="Data Source=SPIROS\SQLX;Initial Catalog=CastleDemo;Integrated Security=SSPI" />
<add
key="proxyfactory.factory_class"
value="NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle" />
and this is the main method that runs the initialization:
static void Main(string[] args)
{
//Configure ActiveRecord source
XmlConfigurationSource source = new XmlConfigurationSource("../../config.xml");
//
//Initialazi ActiveRecord
ActiveRecordStarter.Initialize( source, typeof(Product));
//
//Create Schema
ActiveRecordStarter.CreateSchema();
//
}
OK.. got it working.
The version of a NHibernate that I have requires to have "hibernate" in the key attributes.
example
Instead of this:
<add
key="connection.driver_class"
value="NHibernate.Driver.SqlClientDriver"/>
do like this:
<add
key="hibernate.connection.driver_class"
value="NHibernate.Driver.SqlClientDriver" />
For newer version of NHibernate the opposite works.
这篇关于城堡的ActiveRecord&QUOT;无法编译的映射文件:(串)&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!