I wanted to post a useful information about properties of SharePoint picutre libraries.
ServerUrl = /sites/mysite/MyPictures/logo.jpg
EncodedAbsUrl = http://www.mydomain.com/sites/mysite/MyPictures/logo.jpg
FileRef = /sites/mysite/MyPictures/logo.jpg
FileLeafRef = logo.jpg
EncodedAbsThumbnailUrl = http://www.mydomain.com/sites/mysite/MyPictures/_t/logo_jpg.jpg
EncodedAbsWebImgUrl = http://www.mydomain.com/sites/mysite/MyPictures/_w/logo_jpg.jpg
Freitag, 17. Januar 2014
Dienstag, 17. Dezember 2013
Language issues with SharePoint online and Office 365
What's wrong, when you have set in SharePoint 2013 online all language and region settings to a language, but there are still appearing some labels/alerts, etc. in the previous language? Why does the language setting not work correctly?
A customer of mine had this issue. The solution is, that Microsoft installs the default language according to the country they are billing. That means a German billing address will get a German default language install. In combination with Office 365 there might be still some labels and alerts set to German, even when you changed all language and regional settings to e.g. English.
There is just one way to solve this. You will have to contact Microsoft and ask for a fresh install of your SharePoint 2013 online. This worked for my customer. It seems there is still the step missing, that Microsoft should ask the customer, which default install language they prefer.
A customer of mine had this issue. The solution is, that Microsoft installs the default language according to the country they are billing. That means a German billing address will get a German default language install. In combination with Office 365 there might be still some labels and alerts set to German, even when you changed all language and regional settings to e.g. English.
There is just one way to solve this. You will have to contact Microsoft and ask for a fresh install of your SharePoint 2013 online. This worked for my customer. It seems there is still the step missing, that Microsoft should ask the customer, which default install language they prefer.
Cannot start service spusercodev4 on computer
I tried to deploy a sandbox solution out of Visual Studio 2010 and received the following error:
cannot start service spusercodev4 on computer
Somehow the "Microsoft SharePoint Foundation Sandboxed Code Service" in Central Administration stopped.
Go to Central Administration -> System Settings -> Manage services on server and pick there the service mentioned above and restart. I read on another blog, that also the "Microsoft SharePoint Foundation User Code Service" service might cause this trouble. If my solution does not work, please refer to this blog:
http://blog.dennus.net/2009/11/18/sp2010-spusercodev4-your-new-web-part-project-isnt-deploying/
cannot start service spusercodev4 on computer
Somehow the "Microsoft SharePoint Foundation Sandboxed Code Service" in Central Administration stopped.
Go to Central Administration -> System Settings -> Manage services on server and pick there the service mentioned above and restart. I read on another blog, that also the "Microsoft SharePoint Foundation User Code Service" service might cause this trouble. If my solution does not work, please refer to this blog:
http://blog.dennus.net/2009/11/18/sp2010-spusercodev4-your-new-web-part-project-isnt-deploying/
Donnerstag, 21. November 2013
Custom field type -error
I had a .NET Error when creating a custom field type in my SharePoint list:
Microsoft.SharePoint.SPException: Field type FolderField is not installed properly. Go to the list settings page to delete this field.
at Microsoft.SharePoint.SPFieldCollection.GetDotNetTypeForFieldType(String typeName)
at Microsoft.SharePoint.SPFieldCollection.CreateNewFieldInternal(String typeName, String displayName)
at Microsoft.SharePoint.ApplicationPages.FieldNewPage.Save()
Reason therefore was an error in my fldtypes_MyCustomField.xml.
There I had a wrong FieldTypeClass. It should be this way:
<Field Name="FieldTypeClass">[Class with Namespace Test.MyCustomField], [Assembly-name], Version=1.0.0.0, Culture=neutral, PublicKeyToken=b426d5u8827cb6b6</Field>
Microsoft.SharePoint.SPException: Field type FolderField is not installed properly. Go to the list settings page to delete this field.
at Microsoft.SharePoint.SPFieldCollection.GetDotNetTypeForFieldType(String typeName)
at Microsoft.SharePoint.SPFieldCollection.CreateNewFieldInternal(String typeName, String displayName)
at Microsoft.SharePoint.ApplicationPages.FieldNewPage.Save()
Reason therefore was an error in my fldtypes_MyCustomField.xml.
There I had a wrong FieldTypeClass. It should be this way:
<Field Name="FieldTypeClass">[Class with Namespace Test.MyCustomField], [Assembly-name], Version=1.0.0.0, Culture=neutral, PublicKeyToken=b426d5u8827cb6b6</Field>
Montag, 14. Oktober 2013
file.OpenBinary() - access denied
I ran over an error, which can be confusing. I wanted to get a file in SharePoint 2010 programmatically and suddenly I received the error at file.OpenBinary(), that the access is denied. I checked all the permission and was even more confused, because everything was set correctly. I was accessing via elevated privilages and this made me wonder even more.
The solution was really simple. The path to the file was wrong. Usually I would expect a file not found error message in SharePoint, but it seems an access denied is thrown in this case.
The path was not wrong in a matter, that the library was not existing, it was more, that the path went deeper in the folder structure than there was any existing in the library.
The solution was really simple. The path to the file was wrong. Usually I would expect a file not found error message in SharePoint, but it seems an access denied is thrown in this case.
The path was not wrong in a matter, that the library was not existing, it was more, that the path went deeper in the folder structure than there was any existing in the library.
Donnerstag, 10. Oktober 2013
Secure Store Service SharePoint 2010 GetCredentials Access denied
I had the problem, that I wanted to impersonate to SecureStoreService of SharePoint 2010 programmatically, but received an access denied at the point where the method GetCredentials is called.
This happen to me twice in different scenarios:
1. I tried to impersonate in an Elevated environment. Of course, then the used system account has to be also a member of the SecureStoreService.
2. I undid the impersonation after the code sequence and it seems having different methods calling other methods, impersonated and undid and the wrong place, when other methods tried to access.
That means, be aware which account is currently running the code and that this account is also a member of the SecureStoreService.
Try to keep the impersonation area as small as possible, to impersonation does not interfere with other impersonation-efforts.
This happen to me twice in different scenarios:
1. I tried to impersonate in an Elevated environment. Of course, then the used system account has to be also a member of the SecureStoreService.
2. I undid the impersonation after the code sequence and it seems having different methods calling other methods, impersonated and undid and the wrong place, when other methods tried to access.
That means, be aware which account is currently running the code and that this account is also a member of the SecureStoreService.
Try to keep the impersonation area as small as possible, to impersonation does not interfere with other impersonation-efforts.
Mittwoch, 26. Juni 2013
Can't access the Active Directory
I had a problem on a server to access the Active Directory. The error-message led to the following method:
Server stack trace: at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) at System.DirectoryServices.DirectoryEntry.Bind()
When debugging, I got the error that the Context was null.
What saved my day was to wrap the whole Active Directory performance into an impersonation.
using(HostingEnvironment.Impersonate())
{
My active directory code
}
Server stack trace: at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) at System.DirectoryServices.DirectoryEntry.Bind()
When debugging, I got the error that the Context was null.
What saved my day was to wrap the whole Active Directory performance into an impersonation.
using(HostingEnvironment.Impersonate())
{
My active directory code
}
Donnerstag, 11. April 2013
Resource file usage in SharePoint 2010 with Visual Studio 2010
There are two ways to use resource files in SharePoint.
One is with code-behind and the other is to render it in the control.
In the following image you see version (1) in line 9 and version (2) in line 10

Version 1 requires a resx file in the SharePoint 14 hive 'Resources' folder.
Version 2 requires a deployment to App_GlobalResources folder.
Important, if you want to have your resx file to deployed to the 14 hive, first map your project with the SharePoint Resources folder. Then place your resx file in there and you will need to set the Build Action in the resx property to 'Content' otherwise a deployment to the hive won't take place (file will not be physically copied to the hive folder).

Next thing is to click on your feature and set there the property 'DefaultResourceFile' to the neutral resource file and set 'Require Resources' to true.

How to deploy to the App_GlobalResources:
Create in your SharePoint 2010 project a new item "Empty Element". I called it 'ResourceFiles'.
Then you place your resource file in there. To test properly I named it the same and also added the same key with a different value.

When checking the properties of the resx file, set the Deployment Type to 'AppGlobalResource'

Deploy your solution and then check the result.
In my case according to that code

I had this result
One is with code-behind and the other is to render it in the control.
In the following image you see version (1) in line 9 and version (2) in line 10
Version 1 requires a resx file in the SharePoint 14 hive 'Resources' folder.
Version 2 requires a deployment to App_GlobalResources folder.
Important, if you want to have your resx file to deployed to the 14 hive, first map your project with the SharePoint Resources folder. Then place your resx file in there and you will need to set the Build Action in the resx property to 'Content' otherwise a deployment to the hive won't take place (file will not be physically copied to the hive folder).
Next thing is to click on your feature and set there the property 'DefaultResourceFile' to the neutral resource file and set 'Require Resources' to true.
How to deploy to the App_GlobalResources:
Create in your SharePoint 2010 project a new item "Empty Element". I called it 'ResourceFiles'.
Then you place your resource file in there. To test properly I named it the same and also added the same key with a different value.
When checking the properties of the resx file, set the Deployment Type to 'AppGlobalResource'
Deploy your solution and then check the result.
In my case according to that code
I had this result
Donnerstag, 14. März 2013
ULS Viewer no items
I had the problem, that when I started ULS Viewer, no items where displayed.
Then checking the 14-hive of SharePoint and the log folder, all log files had 0 KB size.
When checking the SharePoint log-settings, everything was set properly.
The problem was, that the disc space ran out. I cleared the disc, so I had at least 1,2 GB space.
I restarted the SharePoint 2010 Tracing (Windows) service.
Then I deleted all the old 0 KB files in the log folder and voila, logs were written to the files and ULS viewer could display them.
Dienstag, 27. November 2012
PublishingWeb unable to create page
I ran into a problem, where I wanted to create a page through PowerShell and then I received errors, when using the PublishingWeb object.
After a while I figured out, that you need to enable the web-scoped feature: SharePoint Server Publishing - 94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb
and then you might have to check if the web, does have a property-bag key "__PagesListId".
If not, create a key and save there the Guid of the document library, where you save the pages in. Default en-US install is "Pages"-library.
If you already do have the key, make sure, that the value corresponds to the Guid of the library, you save the pages in.
After a while I figured out, that you need to enable the web-scoped feature: SharePoint Server Publishing - 94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb
and then you might have to check if the web, does have a property-bag key "__PagesListId".
If not, create a key and save there the Guid of the document library, where you save the pages in. Default en-US install is "Pages"-library.
If you already do have the key, make sure, that the value corresponds to the Guid of the library, you save the pages in.
Dienstag, 22. Mai 2012
Delete items from a SPListItemCollection
Just a really dumb error I made when deleting items from a SPListItemCollection.
This is my code:
SPListItemCollection listCollection = list.GetItems(spQuery);
for (int i = 0; i < listCollection.Count; i++)
{
listCollection.Delete(i); //listCollection.Delete(0)
}
What I did before was to go through the Count() method of the list-item-collection. This is wrong, because the amount of Count() changes during this operation. That means, not everything will be deleted. Use the code bellow. It will loop really through each item and will delete the dynamically changed first item of the list-collection.
SPListItemCollection listCollection = list.GetItems(spQuery);
int counter = listCollection.Count;
for (int i = 0; i < counter; i++)
{
listCollection.Delete(0);
}
That means you should be aware, that the index and the Count() method change, when performing a Delete() operation.
SPListItemCollection listCollection = list.GetItems(spQuery);
for (int i = 0; i < listCollection.Count; i++)
{
listCollection.Delete(i); //listCollection.Delete(0)
}
What I did before was to go through the Count() method of the list-item-collection. This is wrong, because the amount of Count() changes during this operation. That means, not everything will be deleted. Use the code bellow. It will loop really through each item and will delete the dynamically changed first item of the list-collection.
SPListItemCollection listCollection = list.GetItems(spQuery);
int counter = listCollection.Count;
for (int i = 0; i < counter; i++)
{
listCollection.Delete(0);
}
That means you should be aware, that the index and the Count() method change, when performing a Delete() operation.
Freitag, 2. März 2012
SharePoint Webtemplate deployment error
When you want to deploy a webtemplate through Visual Studio and you get the following error:
"Error occurred in deployment step 'Add Solution': Exception from HRESULT: 0x8107026E"
Then you have just a naming problem. The WebTemplate Name-Attribute needs to have the same name as the EmptyElement folder-name.
"Error occurred in deployment step 'Add Solution': Exception from HRESULT: 0x8107026E"
Then you have just a naming problem. The WebTemplate Name-Attribute needs to have the same name as the EmptyElement folder-name.
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.
Error occurred in deployment step 'Activate Features':
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:

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.
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;
}
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;
}
Freitag, 27. Januar 2012
performance counter registry hive consistency -> failed
I had the proeblem, when installing SQL server, that the performance counter registry hive consistency failed.

Searched the internet quite a lot, but then found the correct solution.
http://geekswithblogs.net/robz/archive/2008/08/10/possible-performance-counter-corruption-or-performance-counters-are-just-disabled.aspx
You will have to go into the registry-editor and make there some changes.
1. Go to the HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib and check there in the subfolders, if your language is existing. There seems to be a strange calculation for the LCID.
Take the usual LCID, trim it to the last three digits and then replace the first with 0 and you have the folder-name.
E.g. German (Germany) = LCID 0407 ... trim to the last three digits = 407 ... then replace the first one with 0 = 007. That means, for Germany/German you will need to have a folder called 007 there.
E.g. English (US) = LCID 0409 = 409 = 009 folder-name
Find a list of LCIDs here:
http://msdn.microsoft.com/en-us/goglobal/bb964664

2. If your language folder is there, then go into it and you will need to have two keys in there: Counter and Help.
Just in case you don´t, then create them as multiline strings and copy the values from the 009 folder keys in there.
I also had one case, where I had to set the 'counter' and 'help' keys into every language folder.

3. Then go into both keys and check the last entry value. Usually both seem to incremental. In my case Counter had 2178 and Help 2179.

4. Write down the values and go into the root folder and place those values as a decimal value into the keys Last Counter and Last Help.

This change made it work in my case.
Searched the internet quite a lot, but then found the correct solution.
http://geekswithblogs.net/robz/archive/2008/08/10/possible-performance-counter-corruption-or-performance-counters-are-just-disabled.aspx
You will have to go into the registry-editor and make there some changes.
1. Go to the HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib and check there in the subfolders, if your language is existing. There seems to be a strange calculation for the LCID.
Take the usual LCID, trim it to the last three digits and then replace the first with 0 and you have the folder-name.
E.g. German (Germany) = LCID 0407 ... trim to the last three digits = 407 ... then replace the first one with 0 = 007. That means, for Germany/German you will need to have a folder called 007 there.
E.g. English (US) = LCID 0409 = 409 = 009 folder-name
Find a list of LCIDs here:
http://msdn.microsoft.com/en-us/goglobal/bb964664
2. If your language folder is there, then go into it and you will need to have two keys in there: Counter and Help.
Just in case you don´t, then create them as multiline strings and copy the values from the 009 folder keys in there.
I also had one case, where I had to set the 'counter' and 'help' keys into every language folder.
3. Then go into both keys and check the last entry value. Usually both seem to incremental. In my case Counter had 2178 and Help 2179.
4. Write down the values and go into the root folder and place those values as a decimal value into the keys Last Counter and Last Help.
This change made it work in my case.
Donnerstag, 26. Januar 2012
Powershell script how to run a timer-job
If you want to run a specific timer-job, you can use this code (replace the value in the %%):
$myJob = Get-SPTimerJob "%Add the timer-job-name in here%"
$myJob.RunNow()
$myJob = Get-SPTimerJob "%Add the timer-job-name in here%"
$myJob.RunNow()
Powershell script how to add a field to a list
There might be the need for you to add a field to a list. Here is a script how to manage. Replace the values in %% with your values:
$isRequired = $%enter the boolean value in here%
$listName = "%enter your list-name%"
$siteUrl = "%enter the url of your site%"
$fieldName = "%enter the field-name%"
$fieldtype = "%enter the field-type%"
[void][System.reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$site = new-object Microsoft.SharePoint.SPSite($siteUrl)
$web = $site.rootweb
$spList = $web.Lists[$listName]
if($spList -ne $null)
{
$spList.Fields.Add($fieldName,$fieldtype,$isRequired)
}
$web.Dispose()
$site.Dispose()
$isRequired = $%enter the boolean value in here%
$listName = "%enter your list-name%"
$siteUrl = "%enter the url of your site%"
$fieldName = "%enter the field-name%"
$fieldtype = "%enter the field-type%"
[void][System.reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$site = new-object Microsoft.SharePoint.SPSite($siteUrl)
$web = $site.rootweb
$spList = $web.Lists[$listName]
if($spList -ne $null)
{
$spList.Fields.Add($fieldName,$fieldtype,$isRequired)
}
$web.Dispose()
$site.Dispose()
Powershell script how to create a list
You might want to create a list with Powershell. Here is some code you can use (Replace the values in % with your values):
[void][System.reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$siteUrl = %your site-url%
$site = new-object Microsoft.SharePoint.SPSite($siteUrl)
$web = $site.rootweb
$templateType = $web.ListTemplates["Custom List %or add another list-template%"]
$web.Lists.Add("%enter the list-name you want to use%", "%enter the description%", $templateType)
$web.Dispose()
$site.Dispose()
[void][System.reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$siteUrl = %your site-url%
$site = new-object Microsoft.SharePoint.SPSite($siteUrl)
$web = $site.rootweb
$templateType = $web.ListTemplates["Custom List %or add another list-template%"]
$web.Lists.Add("%enter the list-name you want to use%", "%enter the description%", $templateType)
$web.Dispose()
$site.Dispose()
Abonnieren
Posts (Atom)