VS2015 Hangs/Freezes When Adding MVC Controller or View

This issue came to me today at work where two devs said they couldn’t add a new view to a project.  I repro’d it right away and began investigating.

The problem was isolated to one project in the solution.  I compared references between projects and compared the underlying project files.  Each change that I made to bring them closer into alignment didn’t help.

As said many times, the trick to successful debugging is isolation.  So I unloaded every project except for the web project being tested.  The Add dialogs loaded immediately.  So at this point, I had a workaround.  The projects referenced by the web project (only one) could be unloaded when a new view or controller was needed.

Although this was a workaround, it’s hardly a solution.  I continued down that path of figuring out why the MVC Add dialogs were causing VS to hang.

At one point, I was researching online and I noticed that the Add Controller dialog did appear.  It took over 5 minutes to get to that point, but it did show.  So I tried the Add View dialog and it eventually did show as well.  The dropdown list for model classes was populated with every class from the referenced project.  That might have been the cause of the slowdown.

Something about the dialog struck me funny.  They were different between the two projects.  This suggested to me that they were using different libraries.  I loaded up the NuGet package manager between the two projects and saw the functional project used Razor v2.0, but the failing project used v3.2.3.

I downgraded the failing project to Razor 2.0.  This caused a new problem.  I no longer had context menu options to directly add controllers or views.  Fortunately, I knew where to go for this fix.

In the project file is a node called ProjectTypeGuid, which tells VS what menu options to provide.  I could see the non-working project was missing one of  the guids.  I quick copy between the projects restored the context menu options.

TFS 2012 Fails To Create New Team Project

Today, I went to add a new team project to TFS.  I did the usual steps by giving it a name and choosing the template type (not really relevant to me since I’m a solo programmer).  Visual Studio worked for a bit, then failed with the following error in the log file:

Event Description: TF30162: Task "LinkTypes" from Group "WorkItemTracking" failed
Exception Type: Microsoft.TeamFoundation.Client.PcwException
Exception Message: Page not found.

The Internet had plenty of advice to resolve TF30162 errors, but nothing useful for the specific LinkTypes error.  The only suggestion was to reload the project templates.  I was not able to do that because in TFS 2012, those templates are locked and unable to be uploaded and overwritten.

So I attempted a Repair install of TFS 2012.  That had no effect

I then made sure I was on the latest version of TFS, so I installed Update 4.  My scrum project template went from 2.0 to 2.2, but I still got the exact same error.

I then tried to create a new Project Collection and create a team project in that.  Still, no change.

Then I did a repair install on Visual Studio 2015.  This took a very long time and required two restarts.  And after that, no improvement.

So far, I’ve eliminated the TFS binaries, the TFS database, and the VS binaries.  There’s only one element left – IIS.  And that one seems to have potential because of the PageNotFound error.

Poking around the IIS log files, there’s entries in there like this:

2017-01-09 14:27:23 ::1 GET /tfs/_apis/connectionData connectOptions=IncludeServices&lastChangeId=-1&lastChangeId64=-1 8080 MicrosoftAccount\myaccount@domain.com ::1 VSServices/14.98.25331.0+(devenv.exe+,Pro,+SKU:31) – 404 0 0 1719

Looking at IIS log files prior to when my problem happened,  this 404 error has happened before, too.  but there was also other calls to the service like:

2016-03-25 12:43:46 ::1 OPTIONS /tfs/defaultcollection/_apis/ – 8080 MicrosoftAccount\myaccount@domain.com ::1 Team+Foundation+(devenv.exe,+14.0.24712.0,+Pro,+SKU:31)+VSServices/14.0.24712.0+(devenv.exe+,Pro,+SKU:31) – 404 0 0 8

Two suspects come up in Internet searches: Git and IIS plugins.  Disabling some of the plugins in C:\Program Files\Microsoft Team Foundation Server 11.0\Application Tier\Web Services\bin\Plugins made no difference.

At this point, I suspect an incompatibility between VS2015 and TFS 2012, so I upgrade my TFS install to 2015.  What else could it be?  A call is being made to a REST service that doesn’t exist, or is different enough that the inbound parameters don’t match up.  This TFS upgrade requires SQLExpress to be upgraded as well.  The rabbit hole keeps going deeper and deeper.

After that entire install and restart, I was finally able to create a new Team Project.  The new default project template is “Agile”, not that I care much.

So, the short solution for my error: Upgrade TFS from 2012 to 2015.  It must’ve become incompatible after a VS update somewhere along the way.

Visual Studio 2015 + Silverlight In VB.NET

At work, I was the first to upgrade my machine to Windows 10 and Visual Studio 2015.  Opening our application’s solution, I started resolving little errors here and there.  One problem was not so simple and had a very obscure solution.

We have a small collection of Silverlight apps written in VB.NET.  With the upgrade to Visual Studio 2015, they would not compile.  The errors returned were:

Microsoft (R) Visual Basic Compiler version 1.0.0.50618
Copyright (C) Microsoft Corporation. All rights reserved.

vbc : error BC30002: Type ‘Global.Microsoft.VisualBasic.ApplicationServices.ApplicationBase’ is not defined.
vbc : error BC30002: Type ‘Global.Microsoft.VisualBasic.Devices.Computer’ is not defined.
vbc : error BC30002: Type ‘Global.Microsoft.VisualBasic.MyServices.Internal.ContextValue’ is not defined.
vbc : error BC30002: Type ‘Global.Microsoft.VisualBasic.ApplicationServices.User’ is not defined.
vbc : error BC30002: Type ‘Global.System.ComponentModel.Design.HelpKeyword’ is not defined.

In the course of troubleshooting, I excluded everything from the project except the AssemblyInfo file and I still got the errors.  So I created a new Silverlight project, which built fine, and compared the Detailed compiler output.  The compiler line in the 2015-created project had a slightly different parameter (difference highlighted):

/define:"CONFIG=\"Debug\",DEBUG=-1,TRACE=-1,_MyType=\"Empty\",PLATFORM=\"AnyCPU\",SILVERLIGHT=1"

This clicked with me from my experience with building Silverlight apps for the Zune, where you had to exclude the My namespace that is created with VB.NET applications.  Look at the assemblies being referenced.  ApplicationServices.ApplicationBase (My.Application), Devices.Computer (My.Computer), ApplicationServices.User (My.User).

So, how do you get this extra compile setting?  It’s in the .vbproj – there’s no UI for it.  You’ll have to edit the vbproj file directly.

Unload the Silverlight project, right-click it, and choose Edit .vbproj.  Look for the node <NoStdLib>true</NoStdLib> (there will be one per project configuration) and after it, add: <MyType>Empty</MyType>.  This node is included with new Silverlight projects in VS2015.

Save and reload the project and the MyType flag will be included in the vbc command line, which will allow the Silverlight application to compile.

Of course, a lot of people will probably create a new Silverlight project and move all their code into it and be just as successful.  But, if you don’t want that hassle, or if you just want to know why (as I did), there’s the solution.