SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this simple code in C# using SharePoint:

    SPSite site = new SPSite("http://localhost:333");

When I execute it on a Windows Server 2008 with SharePoint 2010 I get this error:

Retrieving the COM class factory for component with CLSID {BDEADF26-C265-11D0-BCED-00A0C90AB50F} failed due to the following error: 80040154.

When I execute it on Windows Server 2003 with SharePoint 2007 it works well.

Is there a problem in Windows or Sharepoint?
How can I get rid of this error?

share|improve this question
Is SharePoint installed AND working on your 2008 server? – Ryan Jun 22 '11 at 13:42
Do you have an alternate access mapping for "localhost:3333";? SharePoint pays attention to host headers and generally frowns upon "localhost" and IP addresses. Have you tried "http://<server_name>:3333"? – Kirk Liemohn Jun 22 '11 at 13:49
@Kirl There is an error on SPSecurity the execution doesn't get to opening the SPSite – user3470 Jun 22 '11 at 13:56
up vote 4 down vote accepted

Was your code compiled for 64-bit?

share|improve this answer
This is the answer! – Mahendran Govender Jun 17 '15 at 15:39

Try registering OWSSVR.DLL file located under ISAPI folder under 12-hive (MOSS 2007) or SharePoint root (Sharepoint 2010) folder. It is a COM library, you need to register using "REGSVR32 'FULL PATH TO DLL' command.

share|improve this answer
I tried registering like this: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\OWSSVR.DLL but there is an error : C:\Program failed to load. How can i solve the space issue? – user3470 Jun 22 '11 at 13:54
specify the path in quote... – Ashish Patel Jun 22 '11 at 13:59
I got this error: The module was loaded but the call to DLLRegisterServer failed with error code 0X80040201 – user3470 Jun 22 '11 at 14:04
open the command prompt using "Run as Admin" and try again.. D – Ashish Patel Jun 22 '11 at 14:16
Also, change target cpu of your project to "Any Cpu" or "x64" – Ashish Patel Jun 22 '11 at 14:56

For SP2010, Take reference of Microsoft.Sharepoint.dll from 14 hive.You have to rebuild the project for 64 bit

share|improve this answer

Goto your Visual Studio Solution Properties --> Set the Platform target as AnyCPU for Build option. It will fix the issue.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.