c# - 城堡 ActiveRecord "Could not compile the mapping document: (string)"

标签 c# exception activerecord castle

您好,我在尝试初始化 ActiveRecord 时遇到异常,我不知道我遗漏了什么。我正试图说服我工作的公司使用 CaSTLe ActiveRecord,如果我不能演示它是如何工作的,它看起来不会很好。我以前用 CaSTLe ActiveRecord 做过项目,以前从未遇到过这个问题。

谢谢你的帮助

我得到的异常是

堆栈跟踪:

在 CaSTLe.ActiveRecord.ActiveRecordStarter.AddXmlString(配置配置、字符串 xml、ActiveRecordModel 模型) 在 CaSTLe.ActiveRecord.ActiveRecordStarter.AddXmlToNHibernateCfg(ISessionFactoryHolder 持有人,ActiveRecordModelCollection 模型) 在 CaSTLe.ActiveRecord.ActiveRecordStarter.RegisterTypes(ISessionFactoryHolder 持有人,IConfigurationSource 来源,IEnumerable`1 类型, bool 值 ignoreProblematicTypes) 在 CaSTLe.ActiveRecord.ActiveRecordStarter.Initialize(IConfigurationSource 来源,Type[] 类型) 在 C:\Projects\CaSTLeDemo\ConsoleApplication1\Program.cs:line 20 中的 ConsoleApplication1.Program.Main(String[] args) 在 System.AppDomain._nExecuteAssembly(Assembly 程序集,String[] 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()

内部异常:

{“无法编译映射文档:(字符串)”}

下面是我的配置文件:

<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" />

这是运行初始化的主要方法:

    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();
        //
    }

最佳答案

好的..开始工作了。

我拥有的 NHibernate 版本要求在关键属性中包含“hibernate”。

例子

取而代之的是:

<add 
    key="connection.driver_class"
    value="NHibernate.Driver.SqlClientDriver"/>

这样做:

<add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />

对于较新版本的 NHibernate,情况正好相反。

关于c# - 城堡 ActiveRecord "Could not compile the mapping document: (string)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1545346/

相关文章:

php - 在 PHP 中抛出 NotImplementedError?

ruby-on-rails - Rails 记录不关联

ruby-on-rails - Postgres : What does @@ (double at symbol) mean?

c# - 抛出 WebException 的代码在 .NET 3.5 中有效,但在 4.0 中无效

c# - 在 ViewModel SelectedItem 中实现 iNotifypropertychanged 后,在 listview 上不起作用

c# - 如何以编程方式 (C#) 从 POP3 邮件中获取附件?

java - 返回客户异常对象时更改responseStatusCode

javascript - 捕获 Javascript 代码中的空格

ruby-on-rails - 插件中的 Rails ActiveRecord::Observer

c# - 为什么 BotConnector 的行为与模拟器不同?