【发布时间】:2012-11-07 18:46:04
【问题描述】:
我有一个在 Windows 7 上构建良好且没有错误的 Web 项目。当我升级到 Windows 8 时,将项目编译成已编译的网站会引发错误。从 csproj 文件编译(不创建网站)可以正常工作。这是 msbuild 引发的实际错误
ASPNETCOMPILER : 错误 ASPRUNTIME: startIndex 不能大于字符串的长度。 [mycsproj.file.here]
msbuild 正在运行的引发错误的行是
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v / -p my.physical.project.path -u my.physical.project.path\buildartifacts\CompiledWebsite
我还能够通过运行带有 -errorstack 标记的 aspnet_compiler 获得堆栈跟踪,这就是它生成的结果
[ArgumentOutOfRangeException]: startIndex cannot be larger than length of string.
Parameter name: startIndex
at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
at System.Web.Compilation.DiskBuildResultCache.MarkAssemblyAndRelatedFilesForDeletion(String assemblyName)
at System.Web.Compilation.DiskBuildResultCache.CacheBuildResult(String cacheKey, BuildResult result, Int64 hashCode, DateTime utcStart)
at System.Web.Compilation.BuildManager.CacheBuildResultInternal(String cacheKey, BuildResult result, Int64 hashCode, DateTime utcStart)
at System.Web.Compilation.WebDirectoryBatchCompiler.CacheAssemblyResults(AssemblyBuilder assemblyBuilder, CompilerResults results)
at System.Web.Compilation.WebDirectoryBatchCompiler.CompileAssemblyBuilder(AssemblyBuilder builder)
at System.Web.Compilation.WebDirectoryBatchCompiler.<CompileNonDependentBuildProviders>b__0(AssemblyBuilder assemblyBuilder)
at System.Web.Compilation.CompilationUtil.CompileParallel(ICollection assemblyBuilders, Action`1 action)
at System.Web.Compilation.WebDirectoryBatchCompiler.CompileNonDependentBuildProviders(ICollection buildProviders)
at System.Web.Compilation.WebDirectoryBatchCompiler.Process()
at System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors)
at System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors)
at System.Web.Compilation.BuildManager.PrecompileWebDirectoriesRecursive(VirtualDirectory vdir, Boolean topLevel)
at System.Web.Compilation.BuildManager.PrecompileAppInternal(VirtualPath startingVirtualDir, IEnumerable`1 excludedVirtualPaths)
at System.Web.Compilation.BuildManager.PrecompileApp(VirtualPath startingVirtualDir, IEnumerable`1 excludedVirtualPaths)
at System.Web.Compilation.BuildManager.PrecompileApp(ClientBuildManagerCallback callback, IEnumerable`1 excludedVirtualPaths)
at System.Web.Compilation.BuildManagerHost.PrecompileApp(ClientBuildManagerCallback callback, List`1 excludedVirtualPaths)
at System.Web.Compilation.BuildManagerHost.PrecompileApp(ClientBuildManagerCallback callback, List`1 excludedVirtualPaths)
at System.Web.Compilation.ClientBuildManager.PrecompileApplication(ClientBuildManagerCallback callback, Boolean forceCleanBuild)
at System.Web.Compilation.ClientBuildManager.PrecompileApplication(ClientBuildManagerCallback callback)
at System.Web.Compilation.Precompiler.Main(String[] args)
我该如何解决这个问题?由于堆栈跟踪,我认为它与程序集名称有关,但我无法终生弄清楚如何修复它。有人可以帮帮我吗?
【问题讨论】:
-
您找到解决方案了吗?我也有类似的问题。
-
这与我的解决方案中的一些自定义编译目标有关。因为 .net 4.0 的运行时间在 win8 中被 4.5 取代,所以它最初有一些问题。现在似乎很好,我认为框架的一些更新纠正了这个问题。尝试从您的解决方案中删除任何自定义目标,看看是否可行。
-
在我们的例子中,一个 .ashx 文件是某种原因。我删除了处理程序的标记并将其添加到 web.config 作为解决方法。
-
哦,很高兴知道,谢谢分享!
标签: .net-4.0 msbuild windows-8 compiler-errors aspnet-compiler