Broken SharePoint - it's basically an art form

Problematic behavior of web.AddSupportedUILanguage(int lcid) in SharePoint 2013 and 2016

Reading Time: 4 minutes. Every now and then, an API or a method call comes along, that you need to be very careful with. “Microsoft.SharePoint.Client.Web.AddSupportedUILanguage()” seems to be one of them. In this post, I’ll try and document my findings and workarounds for said method!  Issues and solutions Posts Related to “Problematic behavior of web.AddSupportedUILanguage(int lcid) in SharePoint 2013 and 2016”:SharePoint Localization – a (somewhat) comprehensive how-to!SharePoint-Teams -integration using a tabA cautionary tale of relying on the automatic backups in SharePoint Online

Azure Functions SDK 2.0 settings in accessed in C# code

How to access Azure Function App’s settings from C#?

Reading Time: 4 minutes. Different versions of Azure Functions have different ways to access the Azure Function settings. This is another little thing, that I always forget – so better document it somewhere! So, this post describes, how you can access the function’s Application/Environmental settings/variables from your C# code. Posts Related to “How to access Azure Function App’s settings from C#?”:SharePoint Localization – a (somewhat) comprehensive how-to!Privacy PolicyFixing an unhandled exception about StructureMap configuration failing (messed up assembly bindings)

"The resource you are looking for has been removed, had its name changed, or is temporarily unavailable." leads to a 404 error in jQuery.

How to fix an Azure Function (v2) failing with error “The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.”

Reading Time: 4 minutes. This post describes one way to resolve a problem, where you receive an error like “The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.” when calling your Azure Functions. Problem Another day, another simple, yet kind of weird issue to solve! This time I was developing a simple Azure Function to access Microsoft Graph API. This particular issue was kind of bugging, since the error message actually had nothing to do with the actual issue and gave no pointers as to how to fix the issue! I was just developing a function, […]

Office 365 Planner logo

How to form links to Planner tasks

Reading Time: 3 minutes. Office 365 Planner is a neat tool for task management. However, when you, for whatever use case, need to form urls that point you towards a single task (or a bucket, or a plan for that matter), you might run into trouble with how the url is formed. Custom domains actually make it a bit complicated, but luckily there’s a workaround! Description of the issue If you have multiple domains in your Azure AD, your Planner might end up using your custom domain in its urls. However, if you need to develop some multi-tenant code, that works with any tenant […]

Sequence contains more than one element

Easiest way to debug Seed-method in EF Code-first migrations in Configuration.cs when running Update-Database

Reading Time: 5 minutes. This post describes the easiest way to debug the issues that may stop your Seed-method in Configuration.cs from going through. The solution here shows you, how you can get a little bit more information out of the process, without attaching the debugger (there’s another blog post for that!) Description Entity Framework’s code-first migration’s are a beautiful and easy way of managing database schema changes and populating some preliminary data there. Personally I also sometimes use the method for adding some enrichment to data or or custom property values mapping that would otherwise require an additional/external console program. Problem: running the […]

Sequence contains more than one element

Launching a new debugger instance from code in Visual Studio

Reading Time: 2 minutes. This post describes a quick solution to launching a new Visual Studio instance for debugging the code. Where I’ve found this exceptionally useful, has been in debugging code-first migration’s (one of the ways for database initialiation in .NET) Seed-method. It is by default undebuggable, as when you are running Update-Database you can’t really use a -debug switch or anything, and there’s really no way to launch the debugger. Hence the best you can do is using -verbose to get more information. However, if you actually want to see what is happening in the code, here’s the solution. Posts Related to […]


Using Dispatcher to update values in GUI elements from a background thread

Reading Time: 3 minutes. Quick tip: If you’re developing something like a WPF app and you’ll need to update values on the User Interface based on a long-running operation that runs in a background thread (like depicted in my other blog post right here – that post is for a full-trust SharePoint solution, but the basic principle is the same!), you’ll probably need to use Dispatcher, or otherwise you’ll run into issues with the GUI elements being owned by another thread, and therefore forbidding access to them. This can result in an error like this: An unhandled exception of type ‘System.InvalidOperationException’ occurred in WindowsBase.dll   […]


Updating files in an App Part (SharePoint Add-in)

Reading Time: 3 minutes. Luckily, SharePoint Add-ins (or App Parts, like they were called earlier) are slowly getting killed and rooted out of all the sites they once were deployed to – and I don’t think anyone’s going to miss them. However, as so often happens with legacy implementations, there will still be thousands of sites, where SharePoint administrators and developers will be responsible for maintaining and developing the solutions further. This will occasionally require updating app parts, which is a process that kind of sucks. Here I’ll try to simplify the process. Problem(s) Not all the files in an app part are updated during the […]


Fixing the error: “Column XX in table dbo.YY is of a type that is invalid for use as a key column in an index.”

Reading Time: 2 minutes. While using Entity Framework and code-first migrations, Entity Framework (EF) creates the indexes for you – but what if you need to create a custom one, explicitly based on certain field / column? Then you’ll have to tell EF which one to use as a key column. Usually, it’s easy – you just add the following annotation to the columns you’ll be using: [Index(“OfficialIds”, 1)] public int AreaId { get; set; } [Index(“OfficialIds”, 2)] public string EstateId { get; set; } (example stripped of extra code and other columns for clarity) And after adding the migration (Add-Migration… commandlet) you get something like this: CreateIndex(“dbo.Areas”, new[] { “AreaId”, “EstateId” }, name: “OfficialIds”); Okay, nice. Don’t have to create the indexes myself either, so […]

Duplicate String values

Duplicate object values in ASP.NET MVC Display Templates? Easy fix!

Reading Time: 2 minutes. Are you getting duplicate object values (or whatever those Objects output in .ToString())? Eh, so was I, after I edited the display template for String. Found a fix, though. Description Okay – I just ran into one of my more stupid mistakes since.. Well, since forever. I had made some quick and simple edits in String.cshtml display template (among quite a few other edits before building again and seeing what happened), as I added support for Enum values there. After that I started getting duplicate values for String-typed properties.  Apparently, mistakes were made. Solution Luckily, this was easy to fix […]

Update-Database error

Fixing “An error occurred while updating the entries” while running code-first migrations in MVC 5 app

Reading Time: 6 minutes. This post describes an issue with EF’s code-first migrations, when mapping between DB’s DateTime and C#’s DateTime kind of fails, and results in Update-Database cmdlet failing. It’s more or less a prime example of a situation, where the error itself tells very little about the actual issue, and since debugging code-first migrations is kind of difficult (see the best tips for that here!), it’s cumbersome to investigate. Symptoms "An exception of type ‘System.Data.Entity.Infrastructure.DbUpdateException’ occurred in EntityFramework.dll but was not handled in user code." I’ve encountered this error in 2 different situations. Either while inserting new entries into the database (in […]

Stock photo from

Simplest way to create a thread on SharePoint

Reading Time: 2 minutes. This post describes the (probably) easiest and most straightforward way of creating a new Thread in your SharePoint (or any other .NET) server-side / desktop code. Solution: how to create a new Thread Let’s face it – one should not create new Threads lightly when developing SharePoint solutions, but sometimes it’s difficult to avoid. Or sometimes it’s just the simplest way to get around weird framework limitations. Posts Related to “Simplest way to create a thread on SharePoint”:Programmatically creating readable internal names for new SharePoint fieldsSharePoint Localization – a (somewhat) comprehensive how-to!Fixing an unhandled exception about StructureMap configuration failing (messed […]


How to properly use SPWeb.AllowUnsafeUpdates?

Reading Time: 1 minute. At times you may need to allow unsafe updates to SPWeb objects to get your code to run. This, in SharePoint C# code-behind is done by setting SPWeb.AllowUnsafeUpdates to true. However, as this is an exception to security settings, and should generally not be done, it’s a good practice to limit the change to as small a scope as possible – even though the setting is only persisted for the duration of the request (unless the SPWeb object was gotten from SPSite.GetWeb() or SPSite.Webs[]). What to do? I’ve found the easiest way to temporarily allow unsafe updates in a safe […]

SharePoint List Field Name creation dialog - the internal names for created fields are generated from the display name, and often end up being quite messy!

Programmatically creating readable internal names for new SharePoint fields

Reading Time: 4 minutes. This post is about a small programmatic workaround to creating new SPFields for SPLists in SharePoint with human-readable internal names. This is mainly a usability improvement for your editors (and doesn’t change your life that much), but at the very least they will probably appreciate it! In short, I’ll show you how to avoid SharePoint’s dirty encoding (like replacing a space with “_x0020_”). This appliesto when you’re using server-side code to generate fields. Problem: non-readable internal names for SharePoint list fields When you create a new field in SharePoint, SharePoint accepts the following syntax: string internalName = list.Fields.Add("Field name – […]