相关疑难解决方法(0)

什么是NullReferenceException,我该如何解决?

我有一些代码,当它执行时,它抛出一个NullReferenceException,说:

你调用的对象是空的.

这是什么意思,我该怎么做才能解决这个错误?

.net c# vb.net null nullreferenceexception

1876
推荐指数
24
解决办法
127万
查看次数

发布网站,aspnet_compiler空引用异常

我在通过命令行发布解决方案时遇到问题。它在各种项目上间歇性地失败,但是每一次都成功。我同时收到null引用错误和“正在卸载线程正在运行的应用程序域”,这可能只是带有竞争条件的null引用。它似乎仅在具有Web服务的项目上失败(原始的.asmx和带有.svc或无文件激活的WCF)。尽管有时可能会成功,但我认为我们的代码不是问题,尽管我们可以做一些更改以减轻根本原因(无论可能是什么)。

我尝试过/检查过的内容:

  • 我跑来tfpt scorch清理所有本地更改,包括构建输出,但均未成功,因此我知道这不是源目录的问题。
  • 我在C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files(我们使用的是32位)上清除了临时文件,并且看起来还可以,但是仍然有问题。再次发布后,目录仍然为空,因此可能不相关。
  • 使用Process Monitor我发现aspnet_compiler正在写信%LocalAppData%\Temp\Temporary ASP.NET Files。清除这些文件有时似乎奏效,或者也许我很幸运,但是随后又开始失败。我没有发现其他可能相关的东西。
  • 确保我有足够的RAM,似乎没有什么不同。
  • 运行msbuild单线程,没有区别
  • 从命令行运行aspnet_compiler(从MSBuild日志输出获取命令),始终成功
  • 没有压缩的文件夹
  • 我正在使用最新的稳定的Visual Studio(VS 2013更新2),但这没关系,因为我是从命令行运行的,并且所使用的可执行文件在framework目录中。
  • 在某些失败的项目中没有App_Code文件夹

构建输出没有提供任何好的信息,因此我将DebugDiag设置为在崩溃时输出。结果如下:

DetailID = 1
    Count:    1
    Type:     System.NullReferenceException
    Message:  
    Stack:    
        System.Web.Compilation.DiskBuildResultCache.CacheBuildResult(System.String, System.Web.Compilation.BuildResult, Int64, System.DateTime)
        System.Web.Compilation.BuildManager.CacheBuildResultInternal(System.String, System.Web.Compilation.BuildResult, Int64, System.DateTime)
        System.Web.Compilation.WebDirectoryBatchCompiler.CacheAssemblyResults(System.Web.Compilation.AssemblyBuilder, System.CodeDom.Compiler.CompilerResults)
        System.Web.Compilation.WebDirectoryBatchCompiler.CompileAssemblyBuilder(System.Web.Compilation.AssemblyBuilder)
        System.Web.Compilation.WebDirectoryBatchCompiler.CompileAssemblyBuilderParallel(System.Collections.ICollection)
        System.Web.Compilation.WebDirectoryBatchCompiler.CompileNonDependentBuildProviders(System.Collections.ICollection)
        System.Web.Compilation.WebDirectoryBatchCompiler.Process()
        System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(System.Web.Hosting.VirtualDirectory, Boolean)
        System.Web.Compilation.BuildManager.BatchCompileWebDirectory(System.Web.Hosting.VirtualDirectory, System.Web.VirtualPath, Boolean)
        System.Web.Compilation.BuildManager.PrecompileWebDirectoriesRecursive(System.Web.Hosting.VirtualDirectory, Boolean)
        System.Web.Compilation.BuildManager.PrecompileAppInternal(System.Web.VirtualPath, System.Collections.Generic.IEnumerable`1<System.String>)
        System.Web.Compilation.BuildManager.PrecompileApp(System.Web.VirtualPath, System.Collections.Generic.IEnumerable`1<System.String>)
        System.Web.Compilation.BuildManager.PrecompileApp(System.Web.Compilation.ClientBuildManagerCallback, System.Collections.Generic.IEnumerable`1<System.String>)
        System.Web.Compilation.BuildManagerHost.PrecompileApp(System.Web.Compilation.ClientBuildManagerCallback, System.Collections.Generic.List`1<System.String>)
        [GCFrame]
        [GCFrame]
        [ContextTransitionFrame]
        [GCFrame]
        [GCFrame]
        [GCSafeCollectionFrame]
        [GCSafeCollectionFrame]
        [GCSafeCollectionFrame]
        [GCSafeCollectionFrame]
        [GCSafeCollectionFrame]
        [GCSafeCollectionFrame]
        [GCSafeCollectionFrame]
        [TPMethodFrame]
        *** …
Run Code Online (Sandbox Code Playgroud)

msbuild aspnet-compiler

5
推荐指数
1
解决办法
3254
查看次数

ASPRUNTIME:已卸载运行该线程的应用程序域.

我们正在运行Jekins,它开始了一个吞噬构建过程.作为gulp构建过程的一部分,我们触发msbuild任务.

每隔一次构建失败并显示以下消息:

ASPNETCOMPILER:错误ASPRUNTIME:已卸载运行该线程的应用程序域.

无论构建之间的时间跨度如何,这都会发生在所有其他构建中.(即构建,失败,构建,失败).

关于可能导致这种情况的原因以及为什么它只发生在其他构建中的任何想法?

msbuild jenkins gulp

5
推荐指数
2
解决办法
2896
查看次数