SharePoint Developer Center >
SharePoint Products and Technologies Forums
>
SharePoint - Development and Programming
>
Could not load file or assembly microsoft.sharepoint.library on WSS server
Could not load file or assembly microsoft.sharepoint.library on WSS server
- 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
- microsoft.sharepoint.library this dll comes with WSS and it is installed into GAC, make sure that run your code under SPSecurity.RunWithElevatedPrivileges
- Marked As Answer byCharlie WuModeratorThursday, November 12, 2009 1:43 AM
- 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.- Marked As Answer byCharlie WuModeratorThursday, November 12, 2009 1:43 AM
- 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.- Marked As Answer byCharlie WuModeratorThursday, November 12, 2009 1:43 AM
- Proposed As Answer byHereICome SharePoint Wednesday, November 11, 2009 12:44 AM
All Replies
- microsoft.sharepoint.library this dll comes with WSS and it is installed into GAC, make sure that run your code under SPSecurity.RunWithElevatedPrivileges
- Marked As Answer byCharlie WuModeratorThursday, November 12, 2009 1:43 AM
- 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.- Marked As Answer byCharlie WuModeratorThursday, November 12, 2009 1:43 AM
- 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.- Marked As Answer byCharlie WuModeratorThursday, November 12, 2009 1:43 AM
- Proposed As Answer byHereICome SharePoint Wednesday, November 11, 2009 12:44 AM


