Tracking down intermittent 'Object reference not set to an instance of an object.' error on build

后端 未结 11 2596
青春惊慌失措
青春惊慌失措 2020-12-17 15:28

I could use some help trying to track down an intermittent error that I\'ve been having with our ASP.Net project for quite some time.

Intermittently when building th

相关标签:
11条回答
  • 2020-12-17 16:09

    I had this problem for a long time and finally found a solution that work fine for me. It doesn't make sense to me... but altering my web.config file with the following gets definitively rid of this intermittent build error :

    <buildProviders>
        <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
        <!-- add this line below -->
        <remove extension=".rdlc"/> 
     </buildProviders>
    

    Hope this help !

    0 讨论(0)
  • 2020-12-17 16:11

    What's really odd is that it's a run-time error. You shouldn't see that at compile time. Do you have any pre- or post- build steps attached to the solution? Any unit tests you're including with your 'build' process?

    Where does this error show up?

    0 讨论(0)
  • 2020-12-17 16:21

    Run this command at the command line and see if you get some more detailed information

    %WINDIR%\Microsoft.NET\Framework\v3.5\msbuild.exe YourSolution.sln /v:n

    0 讨论(0)
  • 2020-12-17 16:23

    I had this at build time when my project contained custom datasources (my own objects returning collections) with compile errors (that is, my objects had errors).

    You'll also get this error if you try and add a datasource and your project doesn't have any datasources in the project's root (e.g. if you've put all your datasource classes in a subfolder). The only solution I found was to create a datasource in the project's root.

    Sorry not to be more precise, but there seems to be several things that can go wrong with datasources/objects at compile-time.

    0 讨论(0)
  • 2020-12-17 16:24

    Just to clarify, is it the compiler itself that is choking? Are you doing anything weird with #define and #if directives in your code? Maybe something is being done out of order at some point... Just a thought...

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