在过去的几天里,每次我编译我的解决方案(MVC 3 Web应用程序+其他几个项目)时,我都会在错误列表中收到此错误:
Fatal error, cannot continue: The method 'ToStringJS' is not generic (Site.css, line 1, column 1).
由于错误与css文件有关,显然我可以运行该项目。
我没有在css文件中看到错误。
即使我删除了所有css文件内容,我也会收到此错误。
然而,代码突出显示消失了,而intellisense和ReSharper继续工作。
我不确定在哪里寻找这个问题(谷歌搜索没有带来任何结果,无论是Stack Exchange还是其他特定网站)。 这可能是一个ReSharper问题,但我有实际的手段来责怪R#,所以我想从这里开始,然后联系他们。
答案 0 :(得分:10)
你们得到的错误来自Jurassic加载项使用的Chirpy库。
我在Chirpy和Jurassic来源进行了简短的查询,我找到了抛出异常的确切位置,并导致了您所描述的问题。
在Jurassic来源中,转到Jurassic\Compiler\Binders
目录并打开JSBinder.cs
文件。问题出现在protected override void GenerateStub(ILGenerator generator, int argumentCount)
方法中,该方法本身用于生成另一种方法... yadayadayada。这很复杂。
反正。这是来自该文件的代码,它负责您所获得的错误:
// Line 156 (Change Set df266524321d)
// Convert to the target type.
EmitTypeConversion(generator, typeof(object), argument.Type);
if (argument.Type != typeof(ObjectInstance) && inheritsFromObjectInstance == true)
{
// EmitConversionToObjectInstance can emit null if the toType is derived from ObjectInstance.
// Therefore, if the value emitted is null it means that the "thisObject" is a type derived
// from ObjectInstance (e.g. FunctionInstance) and the value provided is a different type
// (e.g. ArrayInstance). In this case, throw an exception explaining that the function is
// not generic.
var endOfThrowLabel = generator.CreateLabel();
generator.Duplicate();
generator.BranchIfNotNull(endOfThrowLabel);
generator.LoadArgument(0);
EmitHelpers.EmitThrow(generator, "TypeError", string.Format("The method '{0}' is not generic", binderMethod.Name));
generator.DefineLabelPosition(endOfThrowLabel);
}
如果您想深入了解一下,可以查看实施Jurassic\Library\Array\ArrayInstance.cs
的{{1}}和Jurassic\Library\Object\ObjectInstance.cs
。同样在Chirpy lib中,public static string ToStringJS(ScriptEngine engine, object thisObject)
文件包含一些有趣的代码行(使用Jurassic的地方)。
我必须承认,我不知道为什么你会得到“致命错误”或者如何解决问题。这需要相当多的测试/调试工作。任何人吗?
无论如何,不要责怪Resharper!这是很棒的软件; - )
答案 1 :(得分:5)
问题出在CSSLint上。您可以下载源代码并尝试修复它,也可以直接禁用它。
转到工具>选项> Chirpy> CssLint
取消选中'运行CSS Lint'框。
如果您遇到与JS相同的问题,那么也要禁用JSHint
答案 2 :(得分:3)
我遇到了这个问题,并通过修复一些无效的CSS解决了这个问题。在我的情况下,无效的CSS是(注意错位的时期?)
#exposeMask{.visibility:hidden;}
在修正错字之后,一切都恢复了生机。
答案 3 :(得分:0)
我可能会迟到一点,但我刚刚将Chirpy插件安装到Visual Studio 2010中,并且几乎立即开始遇到这些错误。
我进入了工具>选项,然后Chirpy> CssLint并取消选中“运行CSS Lint”。田田!没有更多的错误。
答案 4 :(得分:0)
遇到此异常的任何人,请返回您的视图并删除或删除视图中的注释部分。 为什么 使用包含handlebarjs标记“ {{** something }} **”的注释编译视图时 则侏罗纪模板编译器会在编译时遇到问题,从而引发此类异常。是的,我知道这令人困惑!