Spark ViewEngine 与 Glimpse 兼容吗?
刚刚偶然发现了一瞥工具 (getglimpse.com),并想在我的 Spark 驱动的网站(VS2010、MVC3)上尝试一下,但在第一个障碍中就遇到了困难。当我运行我的网站时,出现以下错误:
Unable to cast object of type 'Glimpse.Net.Plumbing.GlimpseView' to type 'Spark.ISparkView'.
不知道这是 Glimpse 问题还是 Spark 问题,但希望对其进行排序,因为 Glimpse 看起来是一个很酷的工具。
Just came across the glimpse tool (getglimpse.com) and would like to try it out on my Spark-powered site (VS2010, MVC3), but come unstuck at the first hurdle. When I run my site I get the following error:
Unable to cast object of type 'Glimpse.Net.Plumbing.GlimpseView' to type 'Spark.ISparkView'.
Don't know whether this is a Glimpse issue or a Spark issue, but would like to get it sorted since Glimpse looks like a cool tool.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是因为
GlimpseView
继承自System.Web.Mvc
命名空间中的IView
,ISparkView
接口也是如此。当 Spark 在找到视图后渲染视图时,它会动态编译和渲染,将其转换为 ISparkView,以便它可以附加模型并执行一些其他操作。我认为 Glimpse 正在拦截视图创建步骤并使用它自己的类型,假设从
IView
继承的任何内容都很好。我猜想可以构建某种适配器来处理 Glimpse 视图,因为这恰好是 Spark 的可扩展点之一。抱歉,这没有多大帮助,但至少它解释了您的例外情况。
更新
Spark 版本 1.5.1.6 中已修复此问题。已在 NuGet 此处
祝一切顺利,
抢
It's because
GlimpseView
inherits fromIView
in theSystem.Web.Mvc
namespace, and so does theISparkView
interface. At the time Spark renders the view after finding it, it compiles and renders on the fly, casting it toISparkView
so that it can attach the Model and do some other bits.I suppose Glimpse is intercepting the view creation step and using it's own type assuming that anything that inherits from
IView
is fine. I guess some kind of adapter can be built to handle Glimpse views as that happens to be once of the extensibility points of Spark.Sorry it doesn't help much, but at least it explains your exception.
Update
This has been fixed in Spark version 1.5.1.6. And is up on NuGet here
All the best,
Rob
我是创始人之一。可以分享一下您的情况吗?
我以前没有使用过 Spark,但根据我的理解,这应该可以正常工作,因为所有内容都已编程到接口。您是否在应用程序启动时将 Spark 注册为视图引擎?
我们有一个支持/问题论坛:https://github.com/Glimpse/Glimpse/issues如果您还需要更多帮助。
I'm one of the founder's of glimpse. Would it be possible to share a bit more about your situation?
I've not used Spark before, but from my understanding this should all work since everything is programmed to interfaces. Are you registering Spark as your view engine in the app start?
We have a support/issues forum at https://github.com/Glimpse/Glimpse/issues if you need more help as well.