Friday, 23 October 2009
Failed to create feature receiver object from assembly
Remember that the class that inherits from SPFeatureReceiver need to be "Public"
Thursday, 8 October 2009
User Profile Import stuck on "Enumerating"
I keep an eye on some of our clients SharePoint farms and today I came across an error in the profile import for one of the SSPs. “The user profile database connection cannot be made, because of error 0x80004005” is displayed on the “User Profiles and Properties” page and the “Profile import status” was only displaying “Enumerating”.
The import cannot be stopped, if the server is restarted then the error doesn´t disappear according to several posts in newsgroups.
So what to do? I checked and double-checked the SSP database and the values in the Profile_Stats, MIPObjects and MIPScheduleJob tables which all had values related to the Profile Import. But nothing that I did could solve the problem.
But then I remembered that the crawler application is based on the good old Indexing Service which means that the registry is also used to store settings. So after some digging I found the solution by changing a value in the registry for the crawler.
Open the registry editor. Browse to “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\12.0\Search\Applications”. Here you will find a key for each SSP in the farm. Drill down to "\Gather\ProfileImport\ContentSources\0" (which is the Full Import) and check the key “CrawlNumberInProgress”. If it´s not “0xffffffff” then the number displayed corresponds to a key under the branch “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\12.0\Search\Applications\\Gather\ProfileImport\Crawls”.
I changed the number in the key “CrawlNumberInProgress” to “0xffffffff” and then restarted the “Office SharePoint Server Search” service for the settings to be applied.
The error message disappeared from “User Profiles and Properties” and I could start a new full import to the “User Profile Import”
Disclaimer: remember to backup your registry before making any changes. I am not responsible for your system damages because of any registry errors
The import cannot be stopped, if the server is restarted then the error doesn´t disappear according to several posts in newsgroups.
So what to do? I checked and double-checked the SSP database and the values in the Profile_Stats, MIPObjects and MIPScheduleJob tables which all had values related to the Profile Import. But nothing that I did could solve the problem.
But then I remembered that the crawler application is based on the good old Indexing Service which means that the registry is also used to store settings. So after some digging I found the solution by changing a value in the registry for the crawler.
Open the registry editor. Browse to “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\12.0\Search\Applications”. Here you will find a key for each SSP in the farm. Drill down to "
I changed the number in the key “CrawlNumberInProgress” to “0xffffffff” and then restarted the “Office SharePoint Server Search” service for the settings to be applied.
The error message disappeared from “User Profiles and Properties” and I could start a new full import to the “User Profile Import”
Disclaimer: remember to backup your registry before making any changes. I am not responsible for your system damages because of any registry errors
Monday, 5 October 2009
Saturday, 26 September 2009
Lifecycle problem with WSPBuilder and EditorPart
I had a problem with the ApplyChanges method in an EditorPart class that was used in a WSPBuilder WebPart class (the default web part that WSPBuilder creates). The CreateChildControls in the WebPart class was triggered before the ApplyChanges method in the EditorPart class. Therefore the web part content was not updated and the page had to be reloaded to show any update to the web part.
In the WebPart class that is created from WSPBuilder the CreateChildControls is triggered from the OnInit method. This has the consequence that the ApplyChanges method in the EditorPart class will be triggered after the CreateChildControls in the WebPart class. My solution was to remove the method call in OnInit and then the ApplyChanges method was firing correctly.
In the WebPart class that is created from WSPBuilder the CreateChildControls is triggered from the OnInit method. This has the consequence that the ApplyChanges method in the EditorPart class will be triggered after the CreateChildControls in the WebPart class. My solution was to remove the method call in OnInit and then the ApplyChanges method was firing correctly.
Saturday, 29 August 2009
The project location is not trusted and a zip file
When opening an unzipped Visual Studio project I got prompted with "The project location is not trusted". The problem was that the zip file was downloaded from an untrusted location and I needed to unblock it first. Right-click on the zip file --> Properties and the click on "Unblock"
Thursday, 2 July 2009
SPListItemVersion and Dates
It seems SPListItemVersion objects are not displaying dates in the correct timezone. I had to convert the date to a DateTime object and the use the ToLocalTime method to get the correct date out.
Monday, 29 June 2009
Outlook 2007 and HTML email
Well, this can seem to be a little of topic :)
I was generating HTML e-mails that are sent via SharePoint (SendEmail method). But the e-mail wouldn´t render correctly in Outlook 2007. The e-mail was just cut off in Outlook 2007. I ran the HTML that was generated in validators and making sure that all tags was closed but nothing seemed to make me come closer to the solution.
Finnaly I stumbled across the solution! The problem was that I created a long string without linebreaks (\r\n)!
So my guess is that Outlook 2007 reads the HTML into a pre-definied string buffer and the parses it for output and in this case the HTML I sent was to long for this buffer.
I was generating HTML e-mails that are sent via SharePoint (SendEmail method). But the e-mail wouldn´t render correctly in Outlook 2007. The e-mail was just cut off in Outlook 2007. I ran the HTML that was generated in validators and making sure that all tags was closed but nothing seemed to make me come closer to the solution.
Finnaly I stumbled across the solution! The problem was that I created a long string without linebreaks (\r\n)!
So my guess is that Outlook 2007 reads the HTML into a pre-definied string buffer and the parses it for output and in this case the HTML I sent was to long for this buffer.
Thursday, 25 June 2009
Unable to break role inheritance
A customer had a problem to break the inheritance from the parent web. The error message on the first page was "500 Internal server error" and when breaking the inheritance from Site Settings was:
“Cannot complete this action.
Please try again. at Microsoft.SharePoint.Library.SPRequestInternalClass.ResetSecurityScope(String bstrUrl, UInt32 dwObjectType, String bstrObjUrl, Guid guidDoc, Boolean bUnique, Boolean bCopyRoleAssignments, Guid& pguidScopeId, Int32& piError)
at Microsoft.SharePoint.Library.SPRequest.ResetSecurityScope(String bstrUrl, UInt32 dwObjectType, String bstrObjUrl, Guid guidDoc, Boolean bUnique, Boolean bCopyRoleAssignments, Guid& pguidScopeId, Int32& piError) “
Inspired by this solution I just broke the inheritance of the permission levels and inherited it again to fix the issue of not being able to break the role inheritance.
Fast recap:
Browse to http:////_layouts/role.asxp
Break the inheritance
Enable the inheritance again
// Henrik
“Cannot complete this action.
Please try again. at Microsoft.SharePoint.Library.SPRequestInternalClass.ResetSecurityScope(String bstrUrl, UInt32 dwObjectType, String bstrObjUrl, Guid guidDoc, Boolean bUnique, Boolean bCopyRoleAssignments, Guid& pguidScopeId, Int32& piError)
at Microsoft.SharePoint.Library.SPRequest.ResetSecurityScope(String bstrUrl, UInt32 dwObjectType, String bstrObjUrl, Guid guidDoc, Boolean bUnique, Boolean bCopyRoleAssignments, Guid& pguidScopeId, Int32& piError) “
Inspired by this solution I just broke the inheritance of the permission levels and inherited it again to fix the issue of not being able to break the role inheritance.
Fast recap:
Browse to http://
Break the inheritance
Enable the inheritance again
// Henrik
Tuesday, 9 June 2009
Another surprise in SharePoint
I have a list with versioning enabled and a "Multiple line of text" field that can not be updated via the UI. The field is also configured to append text to the current text.
When updating the field and using SPItem.SystemUpdate(false) (in code) the field don´t get a new entry (as it does when editing a field of this type via the UI). Nope, it simply overwrites the current text and updates the field.
One solution to this is to concatenate the old value with the new, with the drawback that the datestamp will always stay the same until a new version of the item is created.
I removed the append option and did the appending of the field myself instead.
// Henrik
When updating the field and using SPItem.SystemUpdate(false) (in code) the field don´t get a new entry (as it does when editing a field of this type via the UI). Nope, it simply overwrites the current text and updates the field.
One solution to this is to concatenate the old value with the new, with the drawback that the datestamp will always stay the same until a new version of the item is created.
I removed the append option and did the appending of the field myself instead.
// Henrik
Wednesday, 3 June 2009
"Copy to GAC" problem with WSPBuilder
See this thread for a solution to the problem. It seems that all application pools needs to be running for it to work.
// Henrik
// Henrik
Thursday, 28 May 2009
"The given key was not present in the dictionary"
Error message when activating a feature with field definition included. Could not display any site columns via the site either. Fired up SPM and browsing the Fields collection and got an error message about a field type not correctly installed.
It turned out I had misspelled "Number" to lowercase "number" in my field definition file. Amend the line and upgraded the solution and the problem was resolved
It turned out I had misspelled "Number" to lowercase "number" in my field definition file. Amend the line and upgraded the solution and the problem was resolved
WSPBuilder: Unicode characters
Got this error message from WSPBuilder when building a new WSP file:
"The filename of the CAB file must not contain Unicode characters!"
I had some some swedish characters in my projectfolder name. I removed it and updated the SLN file with the new path. Problem solved.
// Henrik
"The filename of the CAB file must not contain Unicode characters!"
I had some some swedish characters in my projectfolder name. I removed it and updated the SLN file with the new path. Problem solved.
// Henrik
Monday, 6 April 2009
File attachment and Infopath 2003 SP1
We have been working on a small project using Infopath 2003 and MOSS to create a faster way to input information in a list. Among the challenges (which was quite a few despite it was software from MS on both "sides") faced was how to enable uploading a file while submitting information to a list.
Infopath 2003 provides a File Attachment Control which enables the end-user to select and attach a file to the form. Infopath automatically encodes the file in Base64 and adds a dynamic header in the front of the file. So we wanted to use the "AddAttachment" web service available to post the file, one of the parameters is a Base64 encoded string. Great! Well, the header added by Infopath is also included in the encoding. We only have Jscript or VBScript to use in Infopath 2003 if we don´t want to start to deploy extra code on the clients (which I try to prefer to stay away from) and the support for decoding/encoding files in those languages are not to great.
So our solution is to extract the filename from the header (code below) and the attach a list item event receiver for "ItemAttachmentAdded" which decode the file, removes the header and saves the file again serverside.
Here is the code for extracting the filename from an Infopath Base64 encoded attachment:
dim node
Set node = XDocument.DOM.documentElement.selectSingleNode("/my:myFields/my:FileAttchmentControl")
If(node.text <> "") Then
'typecast the node to base64 as Infopath doesn't do this in node definition
node.DataType = "bin.base64"
'convert base64 node value to binary and store in nodeValue byte array
nodeValue = node.nodeTypedValue
dim convertByteArrayToHexString
convertByteArrayToHexString = ""
For intCounter = 1 to LenB(nodeValue)
convertByteArrayToHexString = convertByteArrayToHexString & Right("0" & Hex(AscB(MidB(nodeValue, intCounter, 1))), 2)
If(intCounter = 100) Then 'Assuming that the header is no longer that 100 bytes
exit for
end if
Next
dim filenameBuffer
dim filename
filename = ""
filenameBuffer = 0
'The length of the filenamebuffer is stored on pos 20-24 (byte), which means 41.47 in Hex and 1 as startpos for Arrays
filenameBuffer = getFilenameBuffer(convertByteArrayToHexString,41,47)
'Read the filename from position (49 to filenamebuffer * unicode - "\n") as end char
filename = getFileName(convertByteArrayToHexString,49,filenameBuffer*4 + 49 - 2)
Function getFilenameBuffer(data,startLoop,stopLoop)
dim k
dim filenameBuffer
for k = startLoop to stopLoop step 2
dim y1
dim y2
dim y3
y1 = Mid(data,k,2)
y2 = CLng("&h" & y1)
y3 = y3 + Int(y2)
filenameBuffer = y3
next
getFilenameBuffer = filenameBuffer
End Function
Function getFileName(data,startLoop, stopLoop)
dim k
dim filename
for k = startLoop to stopLoop step 4
dim h1
dim h2
dim h3
h1 = Mid(data,k,2)
h2 = CLng("&h" & h1)
h3 = Chr(h2)
if(h3 <> "") then
filename = filename & Cstr(h3)
end if
next
getFileName = filename
End Function
Infopath 2003 provides a File Attachment Control which enables the end-user to select and attach a file to the form. Infopath automatically encodes the file in Base64 and adds a dynamic header in the front of the file. So we wanted to use the "AddAttachment" web service available to post the file, one of the parameters is a Base64 encoded string. Great! Well, the header added by Infopath is also included in the encoding. We only have Jscript or VBScript to use in Infopath 2003 if we don´t want to start to deploy extra code on the clients (which I try to prefer to stay away from) and the support for decoding/encoding files in those languages are not to great.
So our solution is to extract the filename from the header (code below) and the attach a list item event receiver for "ItemAttachmentAdded" which decode the file, removes the header and saves the file again serverside.
Here is the code for extracting the filename from an Infopath Base64 encoded attachment:
dim node
Set node = XDocument.DOM.documentElement.selectSingleNode("/my:myFields/my:FileAttchmentControl")
If(node.text <> "") Then
'typecast the node to base64 as Infopath doesn't do this in node definition
node.DataType = "bin.base64"
'convert base64 node value to binary and store in nodeValue byte array
nodeValue = node.nodeTypedValue
dim convertByteArrayToHexString
convertByteArrayToHexString = ""
For intCounter = 1 to LenB(nodeValue)
convertByteArrayToHexString = convertByteArrayToHexString & Right("0" & Hex(AscB(MidB(nodeValue, intCounter, 1))), 2)
If(intCounter = 100) Then 'Assuming that the header is no longer that 100 bytes
exit for
end if
Next
dim filenameBuffer
dim filename
filename = ""
filenameBuffer = 0
'The length of the filenamebuffer is stored on pos 20-24 (byte), which means 41.47 in Hex and 1 as startpos for Arrays
filenameBuffer = getFilenameBuffer(convertByteArrayToHexString,41,47)
'Read the filename from position (49 to filenamebuffer * unicode - "\n") as end char
filename = getFileName(convertByteArrayToHexString,49,filenameBuffer*4 + 49 - 2)
Function getFilenameBuffer(data,startLoop,stopLoop)
dim k
dim filenameBuffer
for k = startLoop to stopLoop step 2
dim y1
dim y2
dim y3
y1 = Mid(data,k,2)
y2 = CLng("&h" & y1)
y3 = y3 + Int(y2)
filenameBuffer = y3
next
getFilenameBuffer = filenameBuffer
End Function
Function getFileName(data,startLoop, stopLoop)
dim k
dim filename
for k = startLoop to stopLoop step 4
dim h1
dim h2
dim h3
h1 = Mid(data,k,2)
h2 = CLng("&h" & h1)
h3 = Chr(h2)
if(h3 <> "") then
filename = filename & Cstr(h3)
end if
next
getFileName = filename
End Function
Friday, 3 April 2009
SharePoint Designer - now for free
Microsoft offers SharePoint Designer for free. See the SharePoint Team blog post for more information.
Tuesday, 17 March 2009
Additional user information import with BDC
Been working on an secondary connection to a SQL Server database that will be used to add more information to the user profile properties. Solution includes the BDC application but foremost setting the correct access permission for the account accessing the BDC application.
I use "RevertToSelf" in the ADF which makes the access to the BDC run with the account for the service "Office SharePoint Search Server".
So the account needs "Execute" permissions for the BDC application and all entities, DBDataReader to the SQL Server (or any other read permission) and finally "Manager User Profiles" under "Personalization Permissions". When troupbleshooting this the ULS is yor friend.
Make sure that no other accounts gets permission to the application in BDC, you want to avoid to expose the BDC application to the built-in web parts.
I use "RevertToSelf" in the ADF which makes the access to the BDC run with the account for the service "Office SharePoint Search Server".
So the account needs "Execute" permissions for the BDC application and all entities, DBDataReader to the SQL Server (or any other read permission) and finally "Manager User Profiles" under "Personalization Permissions". When troupbleshooting this the ULS is yor friend.
Make sure that no other accounts gets permission to the application in BDC, you want to avoid to expose the BDC application to the built-in web parts.
Thursday, 12 March 2009
Moving to WSPBuilder
Attended the first Sweden SharePoint User Group Malmö meeting (phew, that was long) yesterday. Karsten was there and talked about his tools WSPBuilder and SPM2007.
We have been using STSDev for sometime now, but it feels like the development have stalled and other participants also noted that you need to fix bugs in the tool to make it work in different situations. So we have decided to switch to WSPBuilder instead for coming projects. Hopefully it cuts down the time developers needs to write code in the OM.
We have been using STSDev for sometime now, but it feels like the development have stalled and other participants also noted that you need to fix bugs in the tool to make it work in different situations. So we have decided to switch to WSPBuilder instead for coming projects. Hopefully it cuts down the time developers needs to write code in the OM.
Friday, 30 January 2009
Response to "JQuery for Everyone: Total Calculated Columns"
Finally there is somekind of light-weight workaround for Calculated Columns and Totals using jQuery and the beloved CEWP. Find the original post here: http://www.endusersharepoint.com/?p=1106 (great work by the way :) ).
I have made an extension to this, so instead of just calculating the last column one can add any column for a total sum.
I use the sortable element ID to find the cellIndex for all rows that needs to be calculated (diidSortMean = a calculated column with the namne "Mean"). I use IE Dev Toolbar for that purpose.
The script currently calculates a total for three columns, but can easily modified in the CalcGroup function. My list is also expanded as default, will do more testing in the weekend.
If you find bugs, please leave a comment.
I have made an extension to this, so instead of just calculating the last column one can add any column for a total sum.
I use the sortable element ID to find the cellIndex for all rows that needs to be calculated (diidSortMean = a calculated column with the namne "Mean"). I use IE Dev Toolbar for that purpose.
The script currently calculates a total for three columns, but can easily modified in the CalcGroup function. My list is also expanded as default, will do more testing in the weekend.
If you find bugs, please leave a comment.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
function addCommas(nStr) {//formats number
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
}
function getCellIndex(elId)
{
var myColumn = $(elId);
var myParent = myColumn.parents('th');
var result = myParent.attr("cellIndex");
return result;
}
function getArrayList(varIndex, groupName)
{
return $("#tbod"+groupName+"> tr").find(">td:eq(" + varIndex+ ")").get(); //array for groups based on cellIndex
}
function getArrayForOutput(varIndex, groupName)
{
return $("#aggr"+groupName+"> tr:first> td:eq(" + varIndex + ")");
}
function CalcGroupPerColumn(groupName,varIndex)
{
var x = 0;
var m = "";
var p1 = "";
var p2 = "";
if (groupName == '') {
$("table.ms-listviewtable:first> tbody:eq(2)").attr("id","tbod");
}
var arrayList = getArrayList(varIndex,groupName);
$.each(arrayList, function(i,e){
x += Number($(e).text().replace(/\$|,|\)/g, "").replace(/\(/g,"-"));
if ($(e).text().indexOf("$") >= 0) { m = "$" };
});
if (x < 0) {//format for negative numbers
p1 = "(";
p2 = ")";
x = Math.abs(x);
}
var aggEl = getArrayForOutput(varIndex,groupName);
if (arrayList.length > 0) {
aggEl
.css("text-align","right")
.html("<b>Total = "+p1+m+addCommas(x.toFixed(2))+p2+"</b>");
}
}
function CalcSqrtPerColumn(groupName, varIndex, sourceValue)
{
var aggEl = getArrayForOutput(varIndex,groupName);
var sqrtVal = Math.sqrt(sourceValue);
if( sqrtVal > 0 )
{
if (aggEl.length > 0) {
aggEl
.css("text-align","right")
.html("<b>Sqrt = "+ addCommas(sqrtVal.toFixed(2)) + " </b>");
}
}
}
function CalcGroup(groupName) {//sums money in specific list column
var meanCellIndex = getCellIndex("#diidSortMean");
var stdDevCellIndex = getCellIndex("#diidSortStd_x002e_dev");
var varianceCellIndex = getCellIndex("#diidSortVariance");
CalcGroupPerColumn(groupName,meanCellIndex);
CalcGroupPerColumn(groupName,varianceCellIndex);
CalcGroupPerColumn(groupName,stdDevCellIndex);
}
//rewrite of WSS function
function ExpGroupRenderData(htmlToRender, groupName, isLoaded)
{
var tbody=document.getElementById("tbod"+groupName+"_");
var wrapDiv=document.createElement("DIV");
wrapDiv.innerHTML="<TABLE><TBODY id=\"tbod"+groupName+"_\" isLoaded=\""+isLoaded+"\">"+htmlToRender+"</TBODY></TABLE>";
tbody.parentNode.replaceChild(wrapDiv.firstChild.firstChild,tbody);
if (CalcGroup) {
CalcGroup(groupName+"_");
}
}
$(function() {
CalcGroup('');
});
</script>
Friday, 23 January 2009
New employeer
Hi all,
Back after a nice christmas vacation and with a new job. I have started to work as a SharePoint consultant for MMP AB in Malmö, where I´ll lead a new focus area regarding SharePoint.
// Henrik
Back after a nice christmas vacation and with a new job. I have started to work as a SharePoint consultant for MMP AB in Malmö, where I´ll lead a new focus area regarding SharePoint.
// Henrik
Friday, 2 January 2009
Tuesday, 18 November 2008
ChiliRec
This is the far coolest I have seen for quite some time. A digital recorder for online radio stations. http://www.chilirec.com. Check it out!
Playlists, top lists, browse per country...
The next thing I need to solve is to have this thing run on SqueezeCenter / SqueezeBox or Popcorn Hour. Might there be a SDK somewhere?
Playlists, top lists, browse per country...
The next thing I need to solve is to have this thing run on SqueezeCenter / SqueezeBox or Popcorn Hour. Might there be a SDK somewhere?
Subscribe to:
Posts (Atom)