我有一個web項目,可以在Windows 7上正常生成,沒有錯誤。當我升級到Windows 8時,將項目編譯到編譯的網站中會引發錯誤。從csproj文件編譯(不創建網站)工作正常。這是msbuild引發的實際錯誤msbuild ASPNETCOMPILER ASPNETRUNTIME startIndex錯誤
ASPNETCOMPILER:error ASPRUNTIME:startIndex不能大於字符串的長度。 [mycsproj.file.here]
說的MSBuild運行所引發錯誤的行
C:\ WINDOWS \ Microsoft.NET \框架\ 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)
我該如何解決這個問題?由於堆棧跟蹤的原因,我認爲它與程序集名稱有關,但我不能爲了我的生活找出解決辦法的方法。有人可以幫我嗎?
您是否找到了解決方案?我有類似的問題。 – Jacob
它與我的解決方案中的一些自定義編譯目標有關。由於win8中.net 4.0的運行時間被替換爲4.5,因此它最初有一些問題。現在看起來沒問題,我認爲框架的一些更新改正了這個問題。嘗試從您的解決方案中刪除任何自定義目標並查看是否有效。 –
在我們的例子中,.ashx文件是某種原因。我刪除了該處理程序的標記,並將其添加到web.config中作爲解決方法。 – Jacob