Visual Studio Extensions for Windows SharePoint Services Error: System.ArgumentException, Value does not fall within the expected range
A common error you may encounter when using VSEWSS 1.3 is “System.ArgumentException, Value does not fall within the specified range.” This post outlines the common causes and resolutions for the issue.
One suggestion I have seen on the web is to delete the pkg directory since it is auto-generated each time. It is important that you do not do this, because some information about the solution and features is stored in files in the pkg directory. In fact, when doing team development with VSEWSS, the pkg directory must be included in the project and source control so other developers can properly package the solution.
The following outlines the common causes and resolutions:
Remove ASP.NET Web Sites from the Solution
In the VSEWSS 1.3 release notes, there is a known issue: “You may receive the error “Value does not fall within the expected range.” When deploying a SharePoint solution that also contains an ASP.NET Web Project.” The resolution is to “use a separate Visual Studio solution for each of the ASP.NET and SharePoint projects.” If you need a web project, use a web application project instead of a web site.
Ensure Files Added as a Link Were Not Moved, Renamed or Deleted
The most common cause for the ArgumentException is that a file referenced in manifest or rootfiles is missing. One of the things I like to do is develop in a separate projects and link items into the deployment project. This allows me to use a web application project and test changes without having to deploy them to SharePoint first. The downside of linking files is that the links aren’t updated if the source file is moved, renamed or deleted. For example, consider the following project where I have an image file to deploy. Note the shortcut icon indicates the image was added as a link:
If I rename the source file in the Contoso.Web project to “pageerr.gif,” VSEWSS packaging will fail because the file is referenced in the manifest and rootfiles, but cannot be found:
To resolve the issue, look for linked files that have a exclamation icon (which can be difficult to see) and re-link them.
Verify your Installation is not Corrupt
This is the least likely cause, but I experienced this one time. To test your installation, create a new SharePoint project using the Empty template. Package the solution from the solution view. Switch to the wsp view and refresh. If there is something wrong with your installation, you will see a message like this:
To fix the issue, uninstall the extensions, download the latest version of the extensions, and re-install. Re-test creating an empty project.
Conclusion
The Visual Studio Extensions for Windows SharePoint Services can substantially increase your SharePoint development productivity. However, when things go wrong, the extensions can be a productivity killer. The error messages often do not contain enough detail to identify the cause and solution. I hope this post saves you many hours of troubleshooting when you receive an ArgumentException.
Comments
- Anonymous
January 19, 2010
Thanks. Saved me hours of messing around. I have had enough of these extensions. WSPBuilder for me. Thanks again