问题描述
我最近问了一个问题有关使用功能NHibernate使用.NET 4 - 我解决了这个问题,但遇到了一个新的
。 摘要
我的主要问题(目前)的配置数据库。我下面本指南,但努力工作,对SQL Server 2008防爆preSS代替,因为这是我将使用,因此我需要学习的。
失败的code:
公共静态ISessionFactory CreateSessionFactory()
{
返回Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008.ConnectionString(C => c.FromConnectionStringWithKey(MSSQL)))
.Mappings(M => m.FluentMappings.AddFromAssemblyOf<程序>())
.ExposeConfiguration(CFG =>新建的SchemaExport(CFG).Create(真,真))
.BuildSessionFactory();
}
当我尝试运行我的应用程序,我得到的最后一行以下异常( .BuildSessionFactory()
):
是什么原因造成的?
在<一个href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=464751">Microsoft连接问题:
也许<$c$c>FluentConfigurationException$c$c>需要一个 [性SecurityPermission]
属性应用到它的 GetObjectData使用()
方法。
否则签出<一href="http://weblogs.asp.net/peterblum/archive/2009/11/06/typeloadexception-based-on-security-transparent-$c$c-level-2.aspx">this博客文章。
修改:被添加最终的解决方案 [SecurityCritical]
到<$c$c>FluentConfigurationException.GetObjectData()$c$c>
I recently asked a question about using Fluent NHibernate with .NET 4 - I solved that problem, but met a new one.
Summary
My main problem (at the moment) is configuring the database. I'm following this guide, but trying to work against SQL Server 2008 Express instead, as that's what I'll be using and thus what I need to learn.
The failing code:
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();
}
When I try to run my application, I get the following exception on the last line (.BuildSessionFactory()
):
What is causing this?
From the Microsoft Connect issue:
Maybe FluentConfigurationException
needs to apply a [SecurityPermission]
attribute to its GetObjectData()
method.
Else check out this blog post.
EDIT: The final solution was adding [SecurityCritical]
to FluentConfigurationException.GetObjectData()
这篇关于奇怪的覆盖问题,流利的NHibernate和.NET 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!