13
votes

I'm writing a console app for SharePoint 2013 on a 64-bit machine. I get this error when I try to execute the program:

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

Please let me know if you've had this problem in the past and can help. Thank you!

7

7 Answers

14
votes

Have you checked the the properties for your project? (solution explorer, right click on the project, click on properties) On the build tab check for that you select "Any CPU".

10
votes

This worked for me:

In Visual Studio: TOOLS>OPTIONS>Projects and Solutions>WEB PROJECT and Use the 64 bit versions of IIS Express for web sites and projects

8
votes

I hit this problem while running a Unit Test (well, an integration test in "Unit Test" clothing). Changing the target for the unit test project just made the tests disappear from the Test Explorer. It is possible to run your tests (at least in VS2013+) as an x64 environment.

In Visual Studio, choose Test > Test Settings > Default Processor Architecture > x64.

https://msdn.microsoft.com/en-us/library/ee782531(v=vs.120).aspx

4
votes

Sometimes, if "Prefer 32-bit" is greyed out, and your Platform Target is already "Any CPU", the problem is that IIS Express is not 32 bit.

The solution is to change the solution's web server to Local IIS.

This blog details the steps in more detail: Platform Not supported Exception when running Visual Studio Web Application

2
votes

What worked for me was changing a registry key:

HCU\Software\Microsoft\VisualStudio\12.0\WebProjects\Use64BitIISExpress

to 1, as shown here:

https://rule30.wordpress.com/2015/06/22/microsoft-sharepoint-is-not-supported-in-32-bit-process-please-verify-that-you-are-running-in-a-64-bit-executable/

1
votes

I got same issue ,and Build tab has same option as Any CPU, still it was not working , I Have selected explicitly x64 as platform target, and application works fine :)

0
votes

for me it was because of invalid reference to Microsoft.Shareppoint.dllafter migrating to SharePoint 2013 in a console application we used for some automation

just add below address of Microsoft.Shareppoint.dll

Correct

C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.dll

you can found this reference to this correct dll , after creating a empty SharePoint 2013 project in your UAT.

I was getting this error inside my Windows 2012 R2 UAT and Visual Studio 2015 Update 1 , when my reference was incorrectly to a dll found in GAC

Incorrect

   C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SharePoint\v4.0_15.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.dll