Sharing my best software development tips and tricks. From quick tips to actual guides and solutions.
This article explains how to get rid of sudden and unexplainable 401 Access Denied errors when trying to authenticate against a fairly fresh Microsoft 365 / SharePoint Online tenant. This issue seems to be caused by a long-ish project to finally retire ACS – Azure Access Control service) on SharePoint (it’s retired everywhere else already!) Note: This is an updating story, as the situation with ACS is definitely… Developing. Yeah, let’s call it that. It’s a developing situation. Problem In the beginning of September, a…Continue reading (Literally) Breaking: Changes to app authentication on SharePoint! 😵
Another day, another variant of AADSTS50011! With a lot of apps and web services using Azure Active Directory for authentication, you’re bound to run into issues, right? Ah well, one would hope to avoid them. But at least this one is usually easy to fix! Problem I’ve encountered 2 different variants of this particular issue – the error message may or may not contain the name of the principal it’s looking for, and the guid of the tenant it’s looking for the principal in. AADSTS500011…Continue reading How to fix “AADSTS50011 – The resource principal named was not found in the tenant”
This article serves as a simple glossary of important MSDN Subscriber links that I always forget – links that Microsoft keeps updating, that is! I’ll be updating the post as need be :) And yes, I do feel a little bit ridiculous about creating an actual article about something as simple as a list of links to stuff that should be easily discoverable by any search engine. But I suppose it is what it is. Anyway, it seems to me like any time I need…Continue reading The all-important MSDN Subscriber links
This article explains how to restore any hidden windows in Visual Studio without resetting your whole window layout, by using a common keyboard shortcut. Problem We’ve all been there – you’re opening a new window in Visual Studio, but your keyboard shortcut or clicking the item in the menu simply seems to do nothing. The window doesn’t show up anywhere. Reason The reason for this (most of the time) is simple: you have the window popped-up and located outside your screen. This happens pretty much…Continue reading How to restore lost windows in Visual Studio?
Hah – another interesting one. This article describes how to resolve an error along the lines of “Microsoft.Data.SqlClient: Microsoft.Data.SqlClient is not supported on this platform.“, thrown by Azure Functions host. Apparently you can run into this issue either on your local development machine or even in Azure. Problem For me, this error popped up after some house cleaning tasks – dependency updates, merging feature branches… You know the stuff. And suddenly, while the Azure Function App would build and run just fine, my SQL calls…Continue reading How to resolve “Microsoft.Data.SqlClient is not supported on this platform.” in an Azure Function App?
This article explains how to perform a very simple and lightweight database connection test for an existing database context. A while ago, I needed to develop a simple API that I can poll from a load balancer to see whether: An Azure service hosting it is up and It has a connection to its SQL database This simple API would be used for monitoring purposes – simple stuff, sure, but what’s the best way to implement this without causing any unnecessary load to the database,…Continue reading How to verify connection to database in Entity Framework Core?
This time, I’m happy to present you perhaps the simplest way of fixing an annoying and persistent issue with a misleading error message! Wait, does that sound familiar? It’s almost like that’s what half of my articles are about… Anyway, I was happily going my way about creating a couple of new fields to an entity and then scaffolding my changes to a new migration using Entity Framework Core’s Add-Migration, but this happened: Build started… Build failed. “Oh”, I thought. “I must have messed something…Continue reading How to resolve persistent “Build started… Build failed.” when trying to run Entity Framework Core commands?
This article offers yet another possible fix to an issue, where trying to call SaveChanges() in Entity Framework Core throws a pretty generic “An error occurred while updating the entries”-exception, and you’re left wondering what in tarnation is wrong this time. And admittedly, that’s a really generic error, so it could be pretty much whatever. But in this article, I’ll go through one possibility – hopefully it helps! Problem So I was just pushing in some new rows to an incredibly simple table in my…Continue reading How to resolve another “An error occurred while updating the entries” exception in Entity Framework Core
Recently, while building an app service to host a .NET Core API, I had to implement the logic for using both Read-Only and Read-Write Database Contexts for Entity Framework Core. In this particular case, it was the same database – just different contexts, because depending on the location of the app service the app was deployed in, read and write operations might actually go to different database instances, That’s really easy, right? Well… Yes and no. Essentially, it’s easy to spin up, but comes with…Continue reading How to implement multiple Connection Strings for one DbContext in EF Core?
This article describes a curious fix I found to an issue where Application Insights (seemingly) crashes your Azure App Service, leaving behind interesting and non-descriptive errors in the Application Event Logs. Problem Does your Application Insights look like this, too? Event logs full of “Production Breakpoints” with weird errors about named pipes? In my case, the errors were something like these below: IfFailRet(pNamedPipe->Read((BYTE*)&controlRequest, sizeof(SnapshotHolderControlStruct))) failed in function CSnapshotHolder::HandleNewPipeConnection: -2147024787 And: CNamedPipe::Read – Read from named pipe failed: 0x8007006D. These errors would always pop up at…Continue reading How to fix weird “Production Breakpoints” errors in an Azure App Service?
A while ago, I had a situation where a DbContext was misbehaving after deployed to an Azure App Service, and I needed to check the connection string it’s using directly in the code. I had reason to think my code was grabbing an outdated connection string and using a wrong database – and as you can probably imagine, that could cause some issues! However, finding the right method actually took me googling, as there were plenty of examples for Entity Framework for .NET Framework, but…Continue reading How to get the EF Core Connection String?
Every now and then comes the need to write your console output to a log file. There’s a simple way to do this in .NET Framework, and quite a few online articles detailing a borderline one-liner on how to do achieve it: Adding a log file listener(s) by calling Debug.Listeners – something like this: TextWriterTraceListener tr1 = new TextWriterTraceListener(System.Console.Out); Debug.Listeners.Add(tr1); TextWriterTraceListener tr2 = new TextWriterTraceListener(System.IO.File.CreateText(“Output.txt”)); Debug.Listeners.Add(tr2); Source However, this doesn’t work in .NET Core anymore. Problem: Everything changes in .NET Core Using the code offered…Continue reading Adding Debug listeners to your console application fails in .NET Core
Every now and then you run into a situation, where you really need to run some SQL against your local development database. That database, at least in my case, is hosted on your local SQL Server Express. Connecting to a local SQL Server should be a walk in a park, right? Eh, well… While using a connection string to connect to said DB is easy, you can’t do that with the SQL Server Management Studio. I wish you could, but hey – it is what…Continue reading How to access local MSSQL server using SQL Server Management Studio?
When you’re in your .NET Core project, it’s always easy: you just register your DbContext in ConfigureServices, and then inject it into whichever Page, View or Controller you might need it in. However, when you have another project or solution you’re working on and you’d still like to use the same DbContext and your entity classes in it, you have to find another way to do it! What should we do, then? Description Let’s first take a look at the use cases and tech stack.…Continue reading How to instantiate your DbContext outside your Data project?
Ran into this one when trying to push my merge from upstream. I was adhering to my own instructions (see below for a link), but got the error (further below) that stopped me from using GitHub Desktop to push (sync) at all. Posts Related to “How to resolve “refusing to allow an integration to create or update .github/workflows/main.yml” on GitHub Desktop?”:The Scary Anatomy of a Microsoft License Fraud5 ways to enable Custom Scripts for a SharePoint site collectionSharePoint Home, Hub, Sites, Start… What?
Ran into another interesting one when working with a .NET Core 3.0 project and Entity Framework Core – this time, RuntimeIdentifier configuration causing trouble. In short, running Update-Database (to apply code-first migrations to your local database) locally would return this, annoying error: Failed to load the dll from [runtimepath]\win-x86\hostpolicy.dll], HRESULT: 0x800700C1 An error occurred while loading required library hostpolicy.dll from [runtimepath]\win-x86\] I suspect this can happen with any x86 runtimeIdentifier, but the one I had specified in my .csproj-file was this: win-x86 This value (or…Continue reading EF Core fails to load hostpolicy.dll when RuntimeIdentifier is win-x86
Just resolved a random issue that’s difficult enough to google, that I think it’s worth documenting! These seem to be popping up whenever you work with anything that’s fairly fresh out of oven… This particular case revolves around Visual Studio being incredibly obnoxious, and starting to throw a ton of errors on code that worked five minutes prior. In my case, the error happened after updates to Visual Studio. Always fun. Symptoms The errors started popping up in Visual Studio. Basically, I just started getting…Continue reading How to fix “The type or namespace name ‘Services’ does not exist in the namespace ‘Microsoft.AspNetCore.Components’ (are you missing an assembly reference?)”
Okay – a quick piece of documentation that was a bit lackluster, so it’s again a good idea to log somewhere. How to package a simple DLL that’s a result of your Azure DevOps Pipeline? In my particular case, I have configured a post-build step to obfuscate the DLL, that’s first built by MSBuild. That works nicely. However, the default way to create a NuGet package, where you select a project (usually you pass the same variable to NuGet pack command that you used earlier…Continue reading Azure DevOps – how to package a single DLL?
This is a tip that should often be the first thing you do in your projects with database backend, no matter which technology you use: Add some basic info about modified and created times, and the user information – so that if something happens, everyone will know who to blame 😉 There’s a lot of great blog articles describing how to do this in .NET Framework, but not that many for .NET Core. It’s very similar, but not the same. I learned that by copy-pasting…Continue reading How to add creator/modified info to all of your EF models at once in .NET Core
This article describes how to fix a situation, where you can’t use any of the navigation properties of your Entity Framework Core entities, since they are all null, despite data being in the database for sure. So, another day, another error. This time I can’t blame SharePoint, since I just messed up with ASP.NET Core and Entity Framework Core. :) Symptoms No matter what I’d do, I was getting null values for my navigation properties on my entities. They’d would always be null during runtime…Continue reading EF Core returns null for a Navigation property