문제

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?

도움이 되었습니까?

해결책

Was your code compiled for 64-bit?

다른 팁

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.

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top