Error
源文件:c:\Projects\WaterfrontSeattle.org\src\Orchard\Logging\OrchardLog4netLogger.cs
Line: 63
来源错误:
Line 61: // Load the log4net thread with additional properties if they are available
Line 62: protected internal void AddExtendedThreadInfo() {
Line 63: if (_shellSettings.Value != null) {
Line 64: ThreadContext.Properties["Tenant"] = _shellSettings.Value.Name;
Line 65: }
Research
从 DuckDuckGoing 中,我们学到了以下内容:当我们尝试访问惰性值时会发生这种类型的错误。 Codeplex 上的一些 Orchard 论坛帖子表明,这意味着该模块已过时,需要更新才能工作。一些 Orchard Gallery 帖子建议清除 Orchard 缓存作为修复。这些对我们来说都不是真的。
我们的解决方法
-
删除应用程序_数据.
- 从所有位置移除模块。
- 重新创建网站。
- 恢复数据库。
- 从 Visual Studio 的包管理器安装模块。
尸检
解决方法中最重要的部分似乎是删除 App_Data。 App_Data 内部是什么导致了错误?我们之前曾尝试删除cache.dat 文件,但没有成功。 App_Data 中还有什么我们可以删除的?
See also
- https://orchard.codeplex.com/discussions/400331 https://orchard.codeplex.com/discussions/400331
- https://orchard.codeplex.com/discussions/402150 https://orchard.codeplex.com/discussions/402150
- https://orchardimagegallery.codeplex.com/workitem/24 https://orchardimagegallery.codeplex.com/workitem/24
- http://gallery.orchardproject.net/List/Modules/Orchard.Module.Four2n.MiniProfiler http://gallery.orchardproject.net/List/Modules/Orchard.Module.Four2n.MiniProfiler
The OP的解决方案 https://stackoverflow.com/a/27161545/1801588只是一个解决方法。这个问题在它的 GitHub 问题线程 https://github.com/OrchardCMS/Orchard/issues/6350:
如果任何租户的 shell 在创建时抛出异常(在DefaultOrchardHost.CreateAndActivateShells()
),例外情况是
应该记录为OrchardLog4netLogger
。然而,记录
方法还尝试记录当前的 shell 名称,该名称是通过以下方式获得的
相同ShellSettings
未能初始化,有效地迫使
使其重新初始化。这导致了递归,最终以InvalidOperationException:
ValueFactory attempted to access the
Value
property of this instance.
due to ShellSettings
惰性初始化
方法调用自己的方法Lazy<>.Value
。这有两个效果。首先,它
隐藏原始异常,用以下内容覆盖它InvalidOperationException
,这使得根本问题变得更加困难
进行调试。其次,由于抛出异常Lazy<>.CreateValue()
被缓存并在每次调用时重新抛出,这使得租户
在 Orchard 重新启动之前无法使用。
这个问题被几个人解决了,包括类似SO问题的答案 https://stackoverflow.com/a/28064086/1801588: in OrchardLog4netLogger.cs
replace
_shellSettings = new Lazy<ShellSettings>(LoadSettings);
with
_shellSettings = new Lazy<ShellSettings>(LoadSettings,
System.Threading.LazyThreadSafetyMode.PublicationOnly);
在 GitHub 讨论中,我们目前正在等待 Orchard 团队确认这将从下一个版本开始成为框架核心的一部分。无论如何,其他几个人证实它有效。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)