我们使用了MVC3应用程序中较少的代码绑定,并且一切都正常工作。在我们的RegisterBundles()中,我们有如下代码:
var bundle = new
Bundle("~/assets/styles/EnhancedLayoutLess")
.Include("~/assets/styles/enhanced-layout.less");
bundle.Transforms.Add(new CssTransformer());
BundleTable.Bundles.Add(bundle);但是,在升级到MVC4和最新版本的Bundle转换器:Core (1.6.28)、BundleTransfomer:LESS (1.6.26)和(1.1.0)之后,当我们试图检索包时,会出现以下错误:
方法未找到:'System.Collections.Generic.IEnumerable
1 System.Web.Optimization.BundleResponse.get\_Files()'. [MissingMethodException: Method not found: 'System.Collections.Generic.IEnumerable1 System.Web.Optimization.BundleResponse.get_Files()'.]BundleTransformer.Core.Transformers.TransformerBase.Process(BundleContext上下文、BundleResponse响应) +0System.Web.Optimization.Bundle.ApplyTransforms(BundleContext上下文、String bundleContent、IEnumerable`1 `1 bundleFiles) +198 ( System.Web.Optimization.Bundle.ProcessRequest(BundleContext context) +269 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +913 System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean& completedSynchronously) +165
有什么建议我该查一下吗?或者如何减少在MVC4下的捆绑工作?
发布于 2013-07-11 21:49:24
虽然,乍一看,这似乎是另一个问题,但这篇文章解决了我的问题:ASP.NET MVC4应用程序无法在产品上编译Bootstrap.LESS,而在dev上工作
这两种情况的根本原因是相同的。显然,在MVC4中,绑定使用了虚拟路径,用于正确解析的导入减少了,现在无法找到依赖的文件。
发布于 2014-01-10 09:38:22
我也遇到了同样的问题,我找到了解决方案:)这个问题是由YuiCompressorTransform类(Yahoo.Yui.Compressor.Web.Optimization)引起的。
Process方法包含以下代码:
// Grab all of the content.
var rawContent = new StringBuilder();
foreach (var fileInfo in response.Files)
{
using (var reader = fileInfo.OpenText())
{
rawContent.Append(reader.ReadToEnd());
}
}但是fileInfo没有OpenText方法。
我已经将它更改为下面的代码:
using (var stream = fileInfo.VirtualFile.Open())
{
var streamReader = new StreamReader(stream);
rawContent.Append(streamReader.ReadToEnd());
streamReader.Close();
}一切都很好。指向正确类的链接:https://gist.github.com/gr4b4z/8349097
发布于 2015-12-09 12:57:57
只有BundleTransformer.Core 1.6.28与MicrosoftWebOptimizationFramework1.1.0不兼容。此时,有必要使用BundleTransformer.Core 1.7.12 Beta 1或等待版本1.7.16的发布。
https://stackoverflow.com/questions/17581096
复制相似问题