Mittwoch, 29. Februar 2012

Error when deploying out of Visual Studio

I received an error when trying to deploy out of Visual Studio:
Error occurred in deployment step 'Activate Features': 0x80070005
The issue that caused this error was, that the user I was logged on my Windows, did not have administrative rights in the site-collection I wanted to deploy to.
I added my Windows user as an site-collection administrator and Voila, it worked.

Montag, 27. Februar 2012

Web templates HRESULT: 0x81070215

I wanted to create a web-template in Sharepoint 2010. This was supposed to substitude my site-definition. When trying to deploy, I received the error on "Add solution" with the error-code: HRESULT: 0x81070215.
I figured out, that I had the onet.xml in my folder, the elements.xml in my folder, but did not set the Deployment-type of the onet.xml correctly. Therefore go to the properties of the onet.xml and set it there. Check out the screenshot below:



Montag, 13. Februar 2012

How to get the IIS-directory of a webapplication with Powershell

There might be the need to get the IIS absolute path of your webapplication.
Here is the Powershell-script with which you can achieve that:

function GetIISPath ([string] $webApplicationName)
{
foreach($app in Get-SPWebApplication)
{
if($app.Name -eq $webApplicationName)
{
$IISSettings = $app.IisSettings[[Microsoft.SharePoint.Administration.SPUrlZone]::Default]
Write-Host $IISSettings.Path
}
}
}



This function writes the absolute path of the overloaded webapplication-name.


Mittwoch, 8. Februar 2012

value does not fall within the expected range -> Sharepoint list

I had the following code:
public static SPListItemCollection GetListItemCollection(string query)
{
SPListItemCollection listitemcollection = null;
SPList list = web.Lists["TestList"];
listitemcollection = list.GetItems(query);
return listitemcollection;
}


the issue was, that I did receive a SPListItemCollection object, but with no fileds in it, when debugging. When trying to access the field, the error displayed was:

I solved the problem in adding a SPQuery object to it. It seems, that the GetItems() method-overload, does not accept the query-string as a string overload. You need to pass it into the property of the SPQuery object and then overload with the object. This worked like a charm. Here the code:

public static SPListItemCollection GetListItemCollection(string query)
{
SPListItemCollection listitemcollection = null;
SPList list = web.Lists["TestList"];
SPQuery spquery = new SPQuery();
spquery.Query = query;
listitemcollection = list.GetItems(spquery);
return listitemcollection;
}