publishing asp.net website give “Object reference not set to an instance of an object.” error

后端 未结 5 953
逝去的感伤
逝去的感伤 2021-02-15 05:05

I am getting fed up with this error. I have search all over the web and tried every possible suggestion to this error I could find.

  1. delete app_code, build, add fil
5条回答
  •  余生分开走
    2021-02-15 05:54

    I had a similar problem when compiling views in MVC WebApplication. NullReferenceException was thrown only when building solution inside VS or MSBuild. Running aspnet_compiler.exe from command line was without errors.

    error ASPRUNTIME: Object reference not set to an instance of an object.
    
    [NullReferenceException]: Object reference not set to an instance of an object.
       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.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.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)
    

    After a day of looking for answers on web and discovering with ProcessMonitor, I found out that it was happening when compiler tried to compile ReportService.svc file. If this file was deleted or extension renamed, everything compiled just fine. Very strange resolution fixed problem of compiling svc files. A few days ago I turned on ntfs compression on this project to save some space. And this was the only problem. When ntfs compression attribute was removed from website folder, NullReferenceException problem was resolved.

提交回复
热议问题