Cannot use SharePoint 2010 API from console application

Suppose you create new console application using Visual Studio 2010 and add reference to SharePoint 2010 main library. When you run application you get the following error: 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)). Same error may also occur in ASP.NET applications that use SharePoint 2010. Here’s the solution.

Make sure you are using .NET Framework 3.5 as target framework. Your application is compiled to 64bit platform.

SP2010: Target platform must be .NET 3.5 and 64 bit

Now compile your app and try to run it. Everything should work fine now.

See also

Leave a Reply

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