Mock Function call to force loading an assembly - how elegant!

New version of Microsoft.IdentityModel.Clients.ActiveDirectory (ADAL.NET) is out – good time to update!

There’s now a new version of the assembly Microsoft.IdentityModel.Clients.ActiveDirectory available – plenty of reasons to update right away! Let me offer you one hot take on the matter since the earlier 3.x -versions of the package had some issues. Why bother updating? In an earlier post, I described an issue I had with Microsoft.IdentityModel.Clients.ActiveDirectory.Platform not getting copied during the build in a referencing project. In 3.17.0, which the developers published this month,…Continue reading New version of Microsoft.IdentityModel.Clients.ActiveDirectory (ADAL.NET) is out – good time to update!

Mock Function call to force loading an assembly - how elegant!

A quick (and handy!) hack to force referenced assembly to getting copied to a project

Visual Studio failing to copy a referenced assembly to a project in build might lead to surprising runtime errors. This post will explain one method of fixing these issues, using Microsoft.IdentityModel.Clients.ActiveDirectory as the example – as earlier versions of that assembly had this issue! Problem After the build, you might get this kind of error: Could not load file or assembly ‘Microsoft.IdentityModel.Clients.ActiveDirectory.Platform, Version=3.13.1.846, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The…Continue reading A quick (and handy!) hack to force referenced assembly to getting copied to a project

Sequence contains more than one element

The easiest way to debug Seed-method in Code-first migrations in Entity Framework

This post describes the easiest way to debug the issues that may stop your Seed-method in Configuration.cs from going through. This problem concerns typically your ASP.NET MVC projects, either on .NET Framework or .NET Core – the same basic idea should work for both situations. 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…Continue reading The easiest way to debug Seed-method in Code-first migrations in Entity Framework

Visual Studio logo

Fixing the “Could not load file or assembly or one of its dependencies” error

This post describes how to fix the “Could not load file or assembly ‘[assemblyname]’ or one of its dependencies. An attempt was made to load a program with an incorrect format.” error.  The solution described in this post shows you how to resolve the issue when you’re deploying from Visual Studio but get an error somewhat like the above when deploying to IIS or when opening your website after the…Continue reading Fixing the “Could not load file or assembly or one of its dependencies” error

Sequence contains more than one element

Launching a new debugger instance from code in Visual Studio

This post describes a quick solution to launching a new Visual Studio instance for debugging the code. There are a lot of applications for this, but where I’ve found it exceptionally useful, has been in debugging the Entity Framework’s code-first migration (one of the ways for database initialization) 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…Continue reading Launching a new debugger instance from code in Visual Studio

No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'

Fixing the “No Entity Framework provider found for the ADO.NET provider with invariant name ‘System.Data.SqlClient'” error

This post describes the fix to THE “No Entity Framework provider found for the ADO.NET provider with invariant name ‘System.Data.SqlClient’” error, which Visual Studio throws at your face when you try to run an application on any Windows-based system (or which you’ve dug out of event logs). Also, your application is probably built on .NET Framework and Entity Framework. Let’s get into it! Error When debugging/running your code, somewhere in your…Continue reading Fixing the “No Entity Framework provider found for the ADO.NET provider with invariant name ‘System.Data.SqlClient’” error

System.InvalidOperationException'

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

If you’re developing something like a WPF app and you 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 probably need to use Dispatcher, or otherwise, you’ll run into issues with the GUI elements being…Continue reading Using Dispatcher to update values in GUI elements from a background thread

IIS8

Exception of type ‘System.OutOfMemoryException’ was thrown.

This post describes one of the more no-brainerish ways of fixing a ‘System.OutOfMemoryException’ exception being thrown in your ASP.Net MVC application using C# and Entity Framework. Problem While developing a web project, for example, an ASP.NET MVC web application that is using EF, sometimes when handling a lot of data or complex entities on your dev machine, you encounter this error: This of course blocks you from debugging or even…Continue reading Exception of type ‘System.OutOfMemoryException’ was thrown.

Spatial SQL types

Solving the “Spatial types and functions are not available …” -problem

This page describes multiple ways to fix the  ‘Spatial types and functions are not available for this provider because the assembly ‘Microsoft.SqlServer.Types’ version 10 or higher could not be found.‘ exception which comes up during debugging or publishing your program, app or service using DbGeography. Symptoms While running a console program or perhaps installing an ASP.NET MVC website on a machine, where SQL Server (apart from the one that comes…Continue reading Solving the “Spatial types and functions are not available …” -problem

entity-framework-logo

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.”

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 a 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…Continue reading 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.”