That x64 setting.

Today the following error was being thrown by a new SharePoint c# application,

“An unhandled exception of type ‘System.Runtime.InteropServices.COMException’ occurred in Microsoft.SharePoint.dll” with the following detail:

“Additional information: Retrieving the COM class factory for component with CLSID {BDEADF26-C265-11D0-BCED-00A0C90AB50F} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).”

The application is being written in Visual Studio 2013, c# for SharePoint 2013 on a Microsoft Server 2012 R2 server.

To get over the issue just change the platform target in the build settings of the project to x64.