Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have this simple code in C# using sharepoint:

SPSecurity.RunWithElevatedPrivileges(delegate()
{
    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?

Thanks alot.

share|improve this question
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 – Moussa Jun 22 '11 at 13:56

3 Answers

up vote 1 down vote accepted

Was your code compiled for 64-bit?

share|improve this answer

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? – Moussa 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 – Moussa 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

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

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.