Object Reference error on build but... no location? - asp.net

It's an aspx web site. It's Huuuge. Oftentimes, we won't see errors until building the entire site. But it's always told us where the error is.
This time, I'm getting an Object reference not set to instance of an object. error with file, no line, no location. Double clicking on the error just does... nothing.
Error 3 Object reference not set to an instance of an object.
I've tried a few things that I've found here and elsewhere but nothing seems to be helping out or giving me more information. I've tried change the verbosity of compiler/build messages but those goggles don't seem to help.
Edit: Very specifically, the first time I try to build the site after opening the project, it says it builds just fine. Trying to build it again causes the error. Closing VS (2013) and reopening the project allows a first time build success and subsequent builds are failures. It should also be noted that it's not actually building anything because it completes far far too quickly - almost instantly.
Can anyone give me some ideas on how to track this down?

It turns out that the VS installation is completely broken. Banging on the keyboard like a monkey and then trying to build succeeds when it should not.

Related

Dot Net Core Build Error on Publish - Targeted tag name cannot be null or whitespace

I'm suddenly not able to publish my dot net core project, having made no known changes, so this seems mysteriously frustrating atm... (compounded by consistent troubles with project build issues for months now, while using dot net core for my back end server).
When I go to publish, it fails and gives me the error message:
"Publishing failed."
Inspecting the logs, I see every single razor view has a warning or error ending with the same message:
"*.cshtml (-1): Targeted tag name cannot be null or whitespace."
And finally, the commandline error:
"C:\Program
Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.razor.viewcompilation\2.0.0\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets(60,5):
Error MSB3073: The command ""dotnet" exec --runtimeconfig"
is spat out, leaving me without even enough of a hint to the problem to even know where to look.
Any ideas what kind of steps I can take to trouble shoot this sort of thing?
If I don't solve this soon I think it's the final straw with dot net core for me... I wanted to to like it... I really did... I've spent more time trying to make it simply build, (following everything by the book too!) than I've spent coding! The biggest headache was definitely the upgrade to dotnetcore 2.0... even with Microsofts instructions.
As I noted in commets I had the same issue as you. I didn't do any significat changes in codebase but suddenly encountered that msdeploy package is failing to built. At the same time rebuilding project in vs and via cli works fine.
It may sound very silly but I just removed obj and bin folders in my project and after then dotnet publish started working fine as before.
I had <Private>false</Private> under one of my References. Simply removing it fixed my issue. I got the idea from here: https://stackoverflow.com/a/46066976/1777780
If deleting bin and obj and restoring then publishing/running do not work for you, try removing anything that appears to be unneeded from your proj.

Errors showing in Qt application - how to not display them in Release

A Qt project gives a number of errors - that I do not actually consider errors I think:
Some examples:
Fontconfig error: "/etc/fonts/conf.d/65-khmer.conf", line 32: out of memory
// ?
QGraphicsItem::ungrabMouse: not a mouse grabber
// i think happens when the mouse grab didn't quite happen, user moved too fast...
A few others
the first one seems it has an answer here https://askubuntu.com/questions/421891/fontconfig-error-out-of-memory
So I cannot fix it through software, the user must fix it... since it is system dependent...
Even built in release, these errors will still show up on command line... Since they do not cause the application to behave abnormally, I don't think the user should see them.
How can I build/deploy the application without these errors showing ?
ideally of course there would be no errors in a deployed application, but I don't know what I can do about those types of errors...
It is possible to redirect a stream (in this case stderr) after the fact using
freopen("/dev/null", "w", stderr);
Just place this in your main before any other code runs and you should be good. Keep in mind that this might need more work on Windows.
If the error message is posted through the Qt Message infrastructure (qDebug etc.) you can set a new message handler through the function qInstallMsgHandler.

finding reason for EXC_BAD_ACCESS - in Xcode4

I get an EXC_BAD_ACCESS error at a place that doesn't have anything to do with the root cause. I fortunately found the reason to be an array that was too small for the following statement [data getBytes:&tcpBuffer length:i];.
Now my question: I tried all these theree methods - but without success:
Using NSZombiesEnabled did not change anything in the debug window printout
When I set the scheme to debug and to use Leaks instrument it starts the leaks instruments but I don't see the debugger.
When I just run the app in iPhone Simulator and the start Instruments separately, selecting the running app as a target (in the pop-up-menu in Instruments) it stops with an error saying something like "couldn't find the target ".
How does one find the root cause in cases like that? Keep in mind, at the end, it wasn't even a Zombie error! This error message is REALLY more confusing than helpful!
(luckily I just thought of my array, but surely, the next time this will haunt me somewhere else)
It's quite likely that the place you get the EXC_BAD_ACCESS will not be related to the root cause. It could be related and could therefore offer a clue. But that's not certain.
To answer your points:
NSZombiesEnabled will only have an effect if you invoke a method on an object that has been deallocated. That might not be the cause of your EXC_BAD_ACCESS.
Using Instruments is separate to the debugger. If you profile in Instruments, the debugger is not active. Basically, it's a different tool.
This should be ok. Check that your Build Configuration is set to "Debug" and not "Release".
Here's a great link on what causes EXC_BAD_ACCESS and how to track down the root problem:
Lou Franco's Understanding EXC_BAD_ACCESS

Is it possible to have the entire contents of a class that tripped an error included in the stacktrace?

A lot of time can pass between the moment a stack trace is generated and the moment the stack trace is thoroughly investigated. During that time, a lot can happen to the file in question, sometimes obscuring the original error. The error might have been fixed in the meantime (overlapping bugs).
Is it possible to get Stacktraces that show the offending file at the time of the error?
Not elegantly, and you normally don't want the user browsing through code that's throwing unexpected exceptions anyway (open door to an attacker).
Usually, what happens in a dev shop is that the user reports an error, stack trace, and the build it occurred on. As a tester, you can grab that build from your archives (you ARE keeping an archive of all supported releases somewhere handy, RIGHT?), install, run, and try to reproduce the error, working with the user to provide additional info as necessary. I've seen very few bugs that couldn't be reproduced EVENTUALLY, even if it required running the program against a backup of the user's production database to do it.
As a developer, you can download that build's source code from your version control repository (you ARE using version control, RIGHT?), and examine the lines in the stack trace to try to discover the problem by inspection, and/or build and run it to reproduce the error. Then, you go back to the latest source version, build, and run the same steps (a UI automation system can help out here), and if you don't get the error, someone else already found and fixed it. If you still get the error, you also got an updated stack trace with lines that match the current build, allowing you to set your breakpoints and step through.
What KeithS said, plus there are ways to capture more helpful state information at the time of the Exception using the Exception.Data property. See http://blog.abodit.com/2010/03/using-exception-data-to-add-additional-information-to-an-exception/
While KeithS' answer as pretty much correct, it can be easier and more elegant than you think. If you can collect a dumpfile (instead of just a stack trace), you can use a Symbol Server and Source Server in combination with your debugger to automatically pull your correct-version code from source control.
For example: if you enable PDB output and source-server integration in MSBuild, and upload the resulting PDBs to a symbol server, Visual Studio can automatically load the correct source control from a TFS or SourceSafe repository based on the information in a minidump.

Decrypting the YSOD, techniques to the mayhem

How many can relate do this?
Server Error in / Application
Object reference not set to an object
Description: Object reference not set to an object.
Exception Details: System.NullReferenceException: Object reference not set to an object.
Source Error:
Line 56: posts.Add(post);
On a more serious note, what are the first things you look for when you see the
yellow screen of death? Half the time the debug trace isn't actually telling you what the problem is (understandable I guess).
I must admit, I still use Response.Write more than I should. I just get lazy going through the debugger. What techniques do you use to debug the problem?
If I'm unable to identify/resolve the issue using the error message that the page presents to me, I will typically try to use the Windows Event Viewer to help me identify what is causing the issue.
For example, SharePoint errors are sometimes far less than descriptive. So, I'll combine what I'm seeing on the Y.S.O.D. with error messages from the Event Viewer to help me narrow down the cause.
I will do my best to ask a co-worker or other associate that I think might have some experience that might help. If I'm still unable to identify the cause, I will resort to Google armed with all the information.
Here's how I try to reduce the number of YSODs. One of the first things I do when starting work on an app is to create a custom exception class.
Add properties such as the SQL
statement being run. Two display
message text fields, one for display
to users, one for display to
developers (in debug mode) Who is
the logged-in user. Get all the form
variables so you know what they were
trying to enter.
Log the errors somewhere (event log
is good, if you can access the web
server; logging to the database is
less successful when so many
exceptions are inability to access
the database).
Create code in the MasterPage or web page base class Page Error events and Application Error events to do the logging.
Create a custom error page. When in
debug mode, the custom error page
displays everything. When not in
debug mode (production), display
only selected properties of the
custom exception.
Investing the time up front to do this will save you many hours of anguish later.
I usually do my debugging on my local machine with the Cassini web server (comes with VS 2005/2008). If I see an exception on my QA or, heaven forbid, my production box it's usually because I forgot to update my connection strings so that they point to the QA/production database instead of my local machine.
In other cases, I've found the stack traces to be very helpful in determining where to provide breakpoints so I step through it in the debugger and examine the data at runtime. The only time I've written any debugging information on the page was when trying to find some performance issues that I couldn't replicate on my developer instance. In this case I wrote some hidden fields that contained timing information about various parts of the render process.
the error info provided, assuming you are in debug mode, will give you information as to what line the error actually occurred on, along with the lines of code leading up to the error. This info should give you a good start on defining where to set your break points for debugging.
I was once in your shoes many moons ago, using response.write for debugging. Once you start using the IDE and debugger as it's intended you'll find yourself pulling out less hair and getting to the solutions much faster.
Also, opening up the immediate window while debugging is gonna make your life even more happy.
Use a decent logging framework such as log4net, and be liberal in your use of DEBUG-level logging.
It's essentially a neater version of your Response.Write approach, which can be left in your production code and "switched on" when required.

Resources