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?

  • 1
    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

Was your code compiled for 64-bit?

  • This is the answer! – Mahendran Govender Jun 17 '15 at 15:39
  • The answer in my case was no. And that was the problem, because it should be. – Alex Oct 5 '17 at 21:32

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.

  • 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
  • 1
    open the command prompt using "Run as Admin" and try again.. D – Ashish Patel Jun 22 '11 at 14:16
  • 1
    Also, change target cpu of your project to "Any Cpu" or "x64" – Ashish Patel Jun 22 '11 at 14:56

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


I tried the following step and it worked for me for the above error.

  • Go to Solution Explorer and press Alt+ enter
  • Select Any CPU in Build option and uncheck the box that says, Prefer 32-Bit.
  • Save the changes and Build your solution.

Now You should be able to Run the program.

Hope this helps.


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy