Every now and again I want to lazily load a properties value using the null-coalescing operator. Inevitably I've forgotten the proper syntax by the next time I want to use it:
public SomeObject PropertyName =>
_someField ?? (_someField = _container.GetInstance<TObject>());
I'm working on a new project. The solution and initial projects were setup by another developer (who did / is doing a great job). When I first attempted to run the project things didn't go quite as expected. Instead of running, the ASP.NET MVC website immediately closed on me. No errors in the output, no exceptions thrown. It didn't matter if I ran it in IIS Express or in a console host.
At first I thought it was an issue with missing dependencies. While I've had Node.js and NPM installed for a long time, I thought there might be a configuration issue between my NPM install and Visual Studio. While that was a problem (thank you very much Mr. Hanselman), it wasn't the root problem.
Next I took a look at the Windows Event View to see what I could find in the system logs. When I tried to run the application via IIS Express it generated the following error:
Failed to start process with commandline '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\ProjectSystem\VSIISExeLauncher.exe" -debug -p "C:\Program Files\dotnet\dotnet.exe" -a "C:\My Dev\Remslogic\RemsLogic\src\RemsLogic\bin\Debug\netcoreapp1.0\RemsLogic.dll" -pidFile "C:\Users\mikel\AppData\Local\Temp\tmp93DD.tmp" -wd "C:\My Dev\Remslogic\RemsLogic\src\RemsLogic"', ErrorCode = '0x80004005'.
According to the Google box, error code 0x80004005 in ASP.NET apparently means it can't connect to the database. I checked my connection strings. Everything looked right.
Finally it occurred to me to look at project.json and see what I might be missing. There it was, plan as day. This project is using .NET Core 1.1. I'm using a different computer than my normal dev work. I only had .NET Core 1.0 installed. You can install .NET core 1.1 here. Be sure you're looking at Current downloads and not LTS.
Moral of the story, always look at project.json before barking up the wrong forest.