Monthly Archives

Listopad 2011

SharePoint: Powershell Get-SPSite in WSS 3.0

By | Powershell, SharePoint | No Comments

This simple Powershell snipplet gets the SPSite site instance in Windows SharePoint Services 3.0. Script also traps the exception in case of non-existence of SharePoint
site located at $url.

function global:Get-SPSite([string]$url) {
$site = $null
trap [Exception] {
continue;
}
$site = new-object Microsoft.SharePoint.SPSite($url)
return $site
}

… and here is an implementation:

$site = Get-SPSite($URL)
if ($site) {
#your code
}
else {
Write-Host -ForegroundColor Red "ERROR: Site $URL has not been found"
}

c#: System.IO.FileNotFoundException in winforms

By | SharePoint, Winforms | No Comments

Have you faced to the FileNotFoundException error message in your WinForms SharePoint application despite the fact that you have all necessary permissions?

System.IO.FileNotFoundException: The Web application at http:// could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.

Maybe you read this article
but the workaround actually does not work? What your winform app deals with app
settings? Nothing, the problem is somewhere else.

Solution: Try to check out winform‘s target platform and server’s platform. They
should be the same. The error occurs in the SPSite constructor, try to  switch to the same
target platform and to avoid the problem.