无法编译映射文档

无法编译映射文档

本文介绍了NHibernate MappingException:无法编译映射文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的开发者网页应用程序NHibernate正在工作只是花花公子。当我预编译和部署该站点时,当创建SessionFactory时,我会收到一个MappingException。



以下是跟踪中的一些信息:

这向我建议,映射文件有错误或无法找到。但是,如果开发应用程序工作正常,那么映射文件在预编译和部署时怎么会有问题?



有没有人有任何建议发生在这里?



谢谢

解决方案

得到它了。在创建SessionFactory期间调用的XmlSerializer类需要对(默认情况下)C:\Windows\TEMP的写入访问,以便它可以生成一些东西并在其中打包。



或者,您可以按照此博客上的hack 。这会更改XmlSerializer存储其shiznit的默认位置。所有您需要做的是在web.config / app.config文件的配置元素中添加以下元素:

  ;&的System.Xml.Serialization GT; 
< xmlSerializer tempFilesLocation =C:\SomeFolder\SomeOtherFolder\WhereeverYouWant/>
< /system.xml.serialization>

第一个解决方案感觉像一个安全问题,第二个解决方案感觉像一个笨拙的黑客,为了预见后果。



为什么这么糟糕的文件?


On my dev web app NHibernate is working just dandy. When I precompile and deploy the site, I get a MappingException when the SessionFactory is created.

Here's some info from the trace:

This suggests to me either that the mapping file has an error or could not be found. But if the dev app works fine, how can there be an issue with the mapping file when it is precompiled and deployed?!

Does anyone have any suggestion as to what might be happening here?

Thanks

解决方案

Okay, I've got it. The XmlSerializer class which is invoked during the creation of the SessionFactory needs write access to (by default) C:\Windows\TEMP so that it can generate some stuff and whack it in there.

Alternatively, you can follow the hack on this blog http://www.hanselman.com/blog/ChangingWhereXmlSerializerOutputsTemporaryAssemblies.aspx. This changes the default location that XmlSerializer stores its shiznit. All you have to do is add the following element within the configuration element of your web.config / app.config file:

<system.xml.serialization>
  <xmlSerializer tempFilesLocation="C:\SomeFolder\SomeOtherFolder\WhereeverYouWant"/>
</system.xml.serialization>

The first solution feels like a security issue, and the second one feels like a clumsy hack with hard-to-foresee consequences.

Why is this so poorly documented?

这篇关于NHibernate MappingException:无法编译映射文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 10:33