I was all set to make my big blogging debut with a brilliant piece about a Visual Studio 2013 bug that I thought I had discovered. Unfortunately, the problem I discovered was much more mundane, but I think it's probably still worth sharing.

A couple of weeks ago, I was setting up a new development instance of SharePoint 2013. My employer is getting ready to deploy it. We're currently using SharePoint 2007, so it's a welcome upgrade. My job is to get up-to-speed on the new features and capabilities, and hopefully provide recommendations on implementing right the first time.

I'm primarily a software developer, so I've been very excited about the new SharePoint apps model. After getting all the server software in working order, I decided to go with Visual Studio 2013 for development. I read through some articles about creating basic SharePoint apps and then proceeded to try and replicate the results. Everything worked as expected for a regular ASP.NET Web Forms application. I was feeling pretty good.

Then I noticed that there's now MVC support for apps for SharePoint. Great! I've been wanting to dig deeper into the MVC approach. It's clearly the direction a lot of places are headed, Microsoft being no exception. So, I click through and create my new MVC App. But when I go to run it, nothing but fail. Unfortunately, I didn't grab a screenshot of the error page, but the error message was: Problem with activating the app web definition. The function throwing the error was: enableModuleFromXml(). The error code: HRESULT 0x80070002.

No problem, I thought, I'll just check Google and be quickly on my way. Wrong again. I seem to have been the only person in the world to encounter this issue. Usually, that means I'm doing something that's very wrong, and probably really, obviously wrong. I tried again with a new project, but got the same results. Then I tried an approach from an older blog post that showed how to build a SharePoint MVC app by creating a forms app, and then replacing the forms project with a blank MVC project. That also ended in utter failure. At least I was getting the same error every time.


The next morning, feeling a little fresher, I noticed that the SharePoint project included some extra files when the MVC project was used from the start, or if it was added to an existing solution using web forms. After some trial and error, I finally discovered that a File element in a Feature was causing the problem. I commented this line out and congratulated myself.

My celebration was short-lived though. One of the other things I found while looking through the project files was this thing called WebGrease. The MVC projects all referenced WebGrease 1.3.0, which was outdated. I updated Visual Studio with the NuGet package for 1.5.2. That did not immediately fix the problem, but after restarting Visual Studio and creating a new SharePoint provider hosted MVC app, everything worked flawlessly. No more mystery feature, no more commenting out the app.config File element.

I don't know if this problem exists on the release version of Visual Studio 2013 as I was using the RTM version. But I think the real lesson here is, always make sure you're using the current versions of your packages. Unless of course, you have some good reason for sticking with the old.