C# – Could not find an implementation of the query pattern for source type – ‘Select’ not found.

Problem Any time you try to use a Linq extension method (such as Select() to transform list elements) and you haven’t added ‘using System.Linq’, you’ll get a compiler error like this: Could not find an implementation of the query pattern for source type ‘Your Type’.  ‘Select’ not found. In newer versions, the error looks like … Read more

System.InvalidOperationException: Objects added to a BindingSource’s list must all be of the same type.

Problem I am building a report using ReportViewer RDLC and I’m trying to bind the data. When I try to add my BindingList to the BindingSource I get the following exception: System.InvalidOperationException: Objects added to a BindingSource’s list must all be of the same type. Here’s the code causing this: Solution Instead of adding the … Read more

ReportViewer doesn’t appear in the toolbox in Visual Studio

Problem You’re trying to use the ReportViewer control in Visual Studio but it’s not in the toolbox. Other symptoms: After manually adding the ReportViewer control to the toolbox clicking Design a new report does nothing. The RDLC report designer does not open and opening the RDLC file just opens the report markup. Solution Note: Tested … Read more

C# – Parsing CSV data when a field has commas

When you have commas in your CSV fields, it creates a conflict with the field delimiting commas. In other words, you can’t tell which data belongs to which field. How you deal with this will depend on one question: is the field with the comma enclosed in quotes? Comma is enclosed in quotes Spreadsheet programs … Read more

C# – How to parse a comma-separated string from app.config

On one project, I had to parse comma-separated values from app.config and use them to make decisions in the code. To make lookups efficient, I put the parsed values into a HashSet. I’ll show how to do this. In this example, I’ll load comma-separated integers from a setting in app.config called “retryStatusCodes”: Note: These integers … Read more