So I've been writing a new Web API course Pluralsight. I am digging in how to handle versioning for an API and I think I've gotten it figured out but it just doesn't work. Throwing a crazy exception and just isn't working. I waste four hours trying to figure it out and I am cursing and grunting. The other people in the coffee shop are staring.
I spend a bunch of time on Google trying to find someone with a similar problem but no luck. Looking at the data and walking through the bug with the debugger didn't yield anything. Desperate, I reach out to Glenn Block himself for an answer. He's very gracious and agrees to help me out with a quick Skype session.
I tell him the story and he seems shocked. He's telling me things to try but I've tried most of them. I can tell by the look on his face that he doubts that this could be a bug…but it might be. So I told him I'd create a quick reproducible example so I could talk with someone on the team. With some things to try and my assignment to reproduce the problem in isolation, he left me to my own devices.
First thing I did was to create the reproducible case…and it worked. Uh oh. It wasn't a bug…it was working *exactly* as intended. Soon after I found the offending bug. I had done two important things wrong:
This happens to developers all the time. It's a knucklehead move for me specifically because this is what I tell developers they have to do. This is part of my debugging speech. I instruct them to reduce and test and repeat until you have the smallest possible set of code that shows the problem or (usually) find the bug in your own code. It works every time…guaranteed. But only when you follow the procedure.
Even more knuckleheaded was not fully reading the stack trace. This would have pointed me to the problem without even creating the repo case. It was my code that was throwing the exception. A dead giveaway. Half-a-day lost because I thought I was smarter than I am.
|Building a Web App with ASP.NET Core, MVC6, EF Core and AngularJS (New)|
|Building a Web App with ASP.NET5, MVC6, EF7, and AngularJS (Retired)|
|Best Practices in ASP.NET: Entities, Validation, and View Models|
|Front-End Web Development Quick Start|
|Lessons from Real World .NET Code Reviews|
|Node.js for .NET Developers|
|Implementing ASP.NET Web API|
|Application Name||WilderBlog||Environment Name||Production|
|Application Ver||184.108.40.206||Runtime Framework||.NETCoreApp,Version=v1.0|
|App Path||D:\home\site\wwwroot||Runtime Version||.NET Core 220.127.116.11|
|Operating System||Microsoft Windows 6.2.9200||Runtime Arch||X86|