gpt4 book ai didi

nhibernate - Fluent NHibernate 和 .NET 4 的奇怪覆盖问题

转载 作者:行者123 更新时间:2023-12-03 18:33:36 25 4
gpt4 key购买 nike

我最近asked a question关于在 .NET 4 中使用 Fluent NHibernate - 我解决了这个问题,但遇到了一个新问题。

摘要
我的主要问题(目前)是配置数据库。我正在关注 this guide ,但尝试使用 SQL Server 2008 Express 代替,因为这是我将使用的内容,因此我需要学习。

失败的代码:

public static ISessionFactory CreateSessionFactory()
{
return Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008.ConnectionString(c => c.FromConnectionStringWithKey("mssql")))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Program>())
.ExposeConfiguration(cfg => new SchemaExport(cfg).Create(true, true))
.BuildSessionFactory();
}

当我尝试运行我的应用程序时,我在最后一行 ( .BuildSessionFactory() ) 收到以下异常:

Inheritance security rules violated while overriding member: 'FluentNHibernate.Cfg.FluentConfigurationException.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.


这是什么原因造成的?

最佳答案

来自 Microsoft Connect issue :

Security attributes need to be re-applied on types that derive from other types that also have security attributes.



也许 FluentConfigurationException 需要申请 [SecurityPermission]归因于其 GetObjectData()方法。

否则退房 this blog post .

编辑 : final solution正在添加 [SecurityCritical] FluentConfigurationException.GetObjectData()

关于nhibernate - Fluent NHibernate 和 .NET 4 的奇怪覆盖问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1924814/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com