SharePoint Developer Center > SharePoint Products and Technologies Forums > SharePoint - Development and Programming > Could not load file or assembly microsoft.sharepoint.library on WSS server
Ask a questionAsk a question
 

AnswerCould not load file or assembly microsoft.sharepoint.library on WSS server

  • Monday, November 02, 2009 9:23 PMStefen Roebke Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I am developing an application that creates an SPFarm object by calling the SPFarm.Open() method to access other Sharepoint Farms on an intranet.  When I run the application on a MOSS server, it functions perfectly as expected.

    However, I have tried it on several WSS servers and it has worked on none of them.  If I am running it from a WSS server, getting the local farm, I receive the error:

    Could not load file or assembly microsoft.sharepoint.library

    If I am trying to access a remote farm, I get:

    Could not load file or assembly microsoft.sharepoint.security

    Shouldn't these DLLs have neeb installed by the wss installation?
    • Moved byPeter Jausovec - MSFT Tuesday, November 03, 2009 12:12 AMMoving to appropriate forum. (From:SharePoint Development)
    •  

Answers

  • Tuesday, November 03, 2009 4:05 AMRiza Ture Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    microsoft.sharepoint.library this dll comes with WSS and it is installed into GAC, make sure that run your code under SPSecurity.RunWithElevatedPrivileges 
  • Wednesday, November 04, 2009 12:58 AMCharlie WuModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    To verify whether it's installed in GAC, check "%windir%\assembly ".

    Although it's installed in GAC, the installation directory maybe different.
    The default directory is "%ProgramFiles%\Common Files\Microsoft Shared\web server extensions\12\ISAPI ".

    Also, please notice that the version matters. Ensure that the versions of the assemblies are the same.
    Keep It Simple and Stupid.
  • Wednesday, November 04, 2009 2:37 AMHereICome SharePoint Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Try the following code:

    SPFarm farm = SPFarm.Local;
    SPWebService service = farm.Services.GetValue<SPWebService>("");

    foreach (SPWebApplication webApp in service.WebApplications)
    {
       
    }

    If you run as in above, you should not get error.  Try to run it using locally rather than running it remotely. 

All Replies

  • Tuesday, November 03, 2009 4:05 AMRiza Ture Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    microsoft.sharepoint.library this dll comes with WSS and it is installed into GAC, make sure that run your code under SPSecurity.RunWithElevatedPrivileges 
  • Wednesday, November 04, 2009 12:58 AMCharlie WuModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    To verify whether it's installed in GAC, check "%windir%\assembly ".

    Although it's installed in GAC, the installation directory maybe different.
    The default directory is "%ProgramFiles%\Common Files\Microsoft Shared\web server extensions\12\ISAPI ".

    Also, please notice that the version matters. Ensure that the versions of the assemblies are the same.
    Keep It Simple and Stupid.
  • Wednesday, November 04, 2009 2:37 AMHereICome SharePoint Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Try the following code:

    SPFarm farm = SPFarm.Local;
    SPWebService service = farm.Services.GetValue<SPWebService>("");

    foreach (SPWebApplication webApp in service.WebApplications)
    {
       
    }

    If you run as in above, you should not get error.  Try to run it using locally rather than running it remotely.