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

后端 未结 5 951
逝去的感伤
逝去的感伤 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:46

    This typically happens when a *.dll.refresh file in the bin directory points to a location that is no longer available. Deleting the *.dll.refresh files should resolve the issue.

    0 讨论(0)
  • 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.<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.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.

    0 讨论(0)
  • 2021-02-15 05:56

    I know this is an old post, but just in case someone will find this usefull:

    The cause of this problem for me was the McAfee anti-virus

    ASPNETCOMPILER(0,0): Error ASPRUNTIME: Object reference not set to an instance of an object

    0 讨论(0)
  • 2021-02-15 05:58

    This error was occurring for me when I tried to compile the project with MSBUILD - it would build fine within Visual Studio, and would even Debug in my local browser. The Publish option within VS worked, as well. But the command-line MSBUILD was causing the project to error out every time.

    I managed to fix this problem in VS 2012 by opening the Property Pages on my Website, opening the 'MSBuild Options' tab, and unchecking the 'Allow this precompiled site to be updatable' option, then hitting 'save all'.

    0 讨论(0)
  • 2021-02-15 06:00

    I had the same experience and removing the compressed flag from the solution directory tree, set the compiler working again.

    0 讨论(0)
提交回复
热议问题