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 was most recently updated on October 9th, 2018.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 […]

Visual Studio logo

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

Reading Time: 2 minutes. This post was most recently updated on October 9th, 2018.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.  Problem Especially while installing a new dev machine, and building your project for the first time, you may end up getting the following exception: Could not load file or assembly ‘<assemblyname>’ or one of its dependencies. An attempt was made to load a program with an incorrect format. No fear, though, as this is usually easily fixed. In quite […]

Applying Entity Framework’s Code-First Migrations against a Database in Azure by running Update-Database

Reading Time: 3 minutes. This post was most recently updated on October 9th, 2018.This post describes how to run Entity Framework’s code-first migrations against a database located in the Windows Azure. This is done by running Update-Database commandlet with suitable switches, see below. The problem and symptoms Okay, so you’re developing your MVC+EF cool web app with a database in Azure, and you’re using code-first migrations. Cool! What’s nice with code-first-migrations is the fact they are run automatically even in the cloud the next time your app is running (as long as you publish your app with that little box ticked – something like […]

IIS8

Exception of type ‘System.OutOfMemoryException’ was thrown.

Reading Time: 3 minutes. This post was most recently updated on October 28th, 2018.This post describes one of the more no-brainerish ways of fixing a ‘System.OutOfMemoryException’ exceptions being thrown in your ASP.Net MVC application using C# and Entity Framework. Problem While developing a web project, for example ASP.NET MVC with EF, sometimes when handling a lot of data or complex entities on your dev machine, you encounter this error: OutOfMemoryException: Exception of type ‘System.OutOfMemoryException’ was thrown.] System.Text.StringBuilder.ToString() +35 System.IO.StreamReader.ReadToEnd() +123 System.Web.Optimization.BundleFile.ApplyTransforms() +74 System.Web.Optimization.DefaultBundleBuilder.BuildBundleContent(Bundle bundle, BundleContext context, IEnumerable`1 files) +472 System.Web.Optimization.Bundle.GenerateBundleResponse(BundleContext context) +127 System.Web.Optimization.Bundle.GetBundleResponse(BundleContext context) +45 System.Web.Optimization.BundleResolver.GetBundleContents(String virtualPath) +166 System.Web.Optimization.AssetManager.DeterminePathsToRender(IEnumerable`1 assets) +205 System.Web.Optimization.AssetManager.RenderExplicit(String tagFormat, String[] […]

Visual Studio settings for "Track my active file in Solution Explorer" - a really useful setting to have enabled, if you ask me!

Tip: Scroll Solution Explorer to current file in Visual Studio 2012, 2013, 2015 and 2017

Reading Time: 2 minutes. This post was most recently updated on October 9th, 2018.This quick post describes how to get the Solution Explorer to actually track your currently open file. For some reason, this extremely useful feature is disabled by default in Visual Studio. Enabling it helps you to better conserve your context, and see which part of your solution you’re in, while you’re developing a complex piece of software. Give it a try, in case you haven’t already! It’s great and extremely useful! 🙂 Posts Related to “Tip: Scroll Solution Explorer to current file in Visual Studio 2012, 2013, 2015 and 2017”:Getting Connect-MsolService […]

Azure SQL Error

Fixing error “Cannot open server – – requested by the login. Client with IP address – – is not allowed to access the server.” in Azure deployments from Visual Studio

Reading Time: 4 minutes. This post was most recently updated on October 9th, 2018.This post describes how to work your way around the exception ‘Cannot open server – requested by login…’ The issue is caused by Azure’s somewhat annoying firewall logic, and might stop you from accessing your databases from your development machine. Symptoms When trying to publish a web project to Azure from Visual Studio, you suddenly get the following (or similar) error message: “Cannot open server ‘xxx.xxx.xxx.xxx’ requested by the login. Client with IP address ‘xxx.xxx.xxx.xxx’ is not allowed to access the server. To enable access, use the SQL Azure Portal or run […]

SharePoint project properties

Visual Studio 2010 fails to show the design view of an aspx-page

Reading Time: 2 minutes. This post was most recently updated on October 9th, 2018.This post is about solving the issue with Visual Studio 2010 failing to show the design view of an .aspx-page. Luckily, it’s an easy and pretty classical fix. Symptoms While trying to view or edit an aspx-page in design mode in Visual Studio 2010, the window is just plain empty and there’s little you can do about it – selecting view markup or hitting F7 may not do anything and restarting the Visual Studio doesn’t help. Solution The Design view requires connection to the SharePoint site where you’ll be deploying the […]

Too long deployment path

The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

Reading Time: 3 minutes. This post was most recently updated on October 9th, 2018.This post describes a few different ways of fixing the error “The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.” one can get when trying to package/publish a SharePoint solution, web site or Azure Webjob. UPDATE 11.4.2016: I actually got this nasty exception on another occasion (Azure webjob publish), so I updated the text accordingly. Symptoms Visual Studio throws the following error when packaging a SharePoint solution to a .wsp […]

Visual Studio's Attach to Process -dialog

Attaching the Visual Studio debugger to the right IIS worker process

Reading Time: 2 minutes. This post was most recently updated on October 9th, 2018.Every now and then comes the time when you’d actually need to debug something, and then you’ll likely be using your Visual Studio to attach the debugger to one or more processes. Using CKSDev to attach to all IIS worker processes (w3wp.exe), or if you don’t use CKSDev, just pressing ctrl+p and selecting the processes from the list, is often a good enough solution. However, sometimes that makes your dev box sluggish, or maybe catches exceptions from code you’re not wishing to debug at the time, and it’d be handier to […]