Platform Not supported Exception when running Visual Studio Web Application

Hi All,

While i was developing a web application that creates an instance of a custom service application using Visual Studio 2013, I was getting this error:

Exception Type: PlatformNotSupportedException

Details:

Microsoft SharePoint is not supported in 32-bit process. Please verify that you are running in a 64-bit executable.


I have another SharePoint web part project that connects with no issues to the SharePoint custom service app, but this web application is throwing this exception! so, the error is related to the IIS express which is the default IIS for VS 2013 web projects.

The error will exist or be thrown when you create any SharePoint object such as: SPSite to connect and then implement your logic.

I googled little bit and i found that some blogs were saying to un check the prefer 23 bit under Build tab in the project properties, In my case this check is grayed out so i don’t have the option to un check it.

In addition to that, by default all SharePoint projects or Web Projects are targeting AnyCPU, so you shouldn’t change this specially if you are connecting or integrating with SharePoint.


The fix:
1) Right click on the web project that you are having this error and click on the web tab.
2) Under Servers, change the selection from IIS express to Local IIS, This will use the local IIS instance which is a 64 bit installation of your SharePoint Development machine.
- Note: This will allow VS 2013 to create a virtual directory and attach the process, so you will be able to debug once you hit F5.
3) Run you project, the code works with no exception when creating any SharePoint object such as a Site or Web…etc.

SharePoint Development Machine Configuration: Win Server 2008 R2 64 bit, VS 2013 latest release.

Happy SharePointg!!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>