File not found

“File not found”-error when trying to activate custom feature on SharePoint

This post is about fixing on of the most non-spesific errors you can get when activating features on SharePoint “File not found”.

Problem

“File not found” is one of the more annoying errors one can stumble upon when trying to activate a feature.

File not found
File not found

There are quite a few reasons that can cause this error, but after the obvious ones (some files failing to be included in the package, botched wsp deployment, errorenous urls in event receiver) one thing to check might be the alternate access mappings.

Solution to the “File not found” exception

In our case, we had an event receiver with a code similar to this:

SPList list = ... // logic for finding out a certain list, omitted for clarity

(using SPSite site = new SPSite (list.ParentWeb)) {

//...

}

This code worked fine in multiple development environments, but when deployed to acceptance testing environment, feature activation failed because of “File not found”-error, both when accessing the site collection features using web browser and PowerShell. Due to certain authentication settings, we were accessing the site using a localhost:123 -typed address, but the list.ParenWeb returned an address with the actual, configured host header – therefore the code above always failed when trying to access the code inside the using -block.

Reason for also the PowerShell failing is not clear, as we were using the actual address (instead of localhost) and still had the same error, but at least we were able to activate the feature using the browser GUI.

The following two tabs change content below.

Antti K. Koskela

Solutions Architect / Escalations Engineer at Koskila / Norppandalotti Software / Valo Solutions
Antti Koskela is a proud digital native nomadic millenial full stack developer (is that enough funny buzzwords? That's definitely enough funny buzzwords!), who works as a Solutions Architect for Valo Intranet, the product that will make you fall in love with your intranet. Working with the global partner network, he's responsible for the success of Valo deployments happening all around the world. He's been a developer from 2004 (starting with PHP and Java), and he's been bending and twisting SharePoint into different shapes since MOSS. Nowadays he's not only working on SharePoint, but also on .NET projects, Azure, Office 365 and a lot of other stuff. This is his personal professional (e.g. professional, but definitely personal) blog.

Let me know your thoughts!