<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Life of a Hungarian SharePoint Geek</title>
	<atom:link href="http://vspug.com/pholpar/feed/" rel="self" type="application/rss+xml" />
	<link>http://vspug.com/pholpar</link>
	<description>Just another VSPUG - Virtual SharePoint User Group weblog</description>
	<lastBuildDate>Fri, 12 Jun 2009 22:19:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>I got tired of attaching debugger to w3wp.exe. And you?</title>
		<link>http://vspug.com/pholpar/2009/06/12/i-got-tired-of-attaching-debugger-to-w3wp-exe-and-you/</link>
		<comments>http://vspug.com/pholpar/2009/06/12/i-got-tired-of-attaching-debugger-to-w3wp-exe-and-you/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 22:19:00 +0000</pubDate>
		<dc:creator>pholpar</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[As a SharePoint developer, I spend most of my days developing and testing web parts, custom pages, fields and event receivers. Part of this activity is debugging, where one should attach the debugger to the w3wp.exe process instance that belongs to the application pool of the web site we developing on.If you have done that [...]]]></description>
			<content:encoded><![CDATA[<div style="border-right:medium none;padding-right:0cm;border-top:medium none;padding-left:0cm;padding-bottom:0cm;border-left:medium none;padding-top:0cm;"><span style="font-size:10pt;color:black;font-family:&#39;Arial&#39;,&#39;sans-serif&#39;;">As a SharePoint developer, I spend most of my days developing and testing web parts, custom pages, fields and event receivers. Part of this activity is debugging, where one should attach the debugger to the w3wp.exe process instance that belongs to the application pool of the web site we developing on.<br />If you have done that yet, you know it is not an exciting task to select the correct process if you have dozens of instances. You can do that by trial and error, and checking if the red lights next to the breakpoints are turned on, or you should look for the next instance. It is one step better to run iisapps.vbs as described <a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/b8721f32-696b-4439-9140-7061933afa4b.mspx?mfr=true">here</a>, and use the process id it displays for the correct application pool, but it is still a cumbersome manual process, that a developer does not enjoy.<br />Developers enjoy development, and developing tools that help development. A good platform for those tools is the Visual Studio IDE and in that environment maybe the simplest way to create tools is writing macros.<br /></span><span style="font-size:10pt;font-family:&#39;Arial&#39;,&#39;sans-serif&#39;;">To help my job I created a macro in Visual Studio 2005 that attaches the debugger to the w3wp.exe instance of the configured application pool. I hope it works for Visual Studio 2008 too, but I have not tested it with that yet.</p>
<p><b style="mso-bidi-font-weight:normal;">Configuring the name of the application pool in Visual Studio<br /></b>The configuration can be done using the project properties. These properties are stored in the csproj.user file of the project, so if you use version control and work in a team, the value can be different for teammates. I selected the Command line arguments text field on the Debug tab to store the name of the application pool we want to attach the debugger to.<br />There might be multiple projects in the solution, and each project may be multiple configuration (like debug or release), so I decided to use the debug configuration for the first startup project. It is important, because there may be <a href="http://msdn.microsoft.com/en-us/library/ms165413(VS.80).aspx">multiple startup projects in a solution</a>.</p>
<p><a href="/oldweblogfiles/pholpar.AttachDebugger/ProjDebugProps.PNG"><img border="0" src="/oldweblogfiles/pholpar.AttachDebugger/ProjDebugProps.PNG" alt="  " /></a></p>
<p><b style="mso-bidi-font-weight:normal;">The macro</b><br />After this introduction, let&rsquo;s see the code of the macro. We need the import the following namespaces:<br /></span><span style="font-size:10pt;font-family:&#39;Courier New&#39;;"><br />Imports System<br />Imports EnvDTE<br />Imports EnvDTE80<br />Imports System.Management<br />Imports System.Text.RegularExpressions<br /></span><span style="font-size:10pt;font-family:&#39;Arial&#39;,&#39;sans-serif&#39;;"><br />The entry point for the macro is the AttachMacro sub. In that we first determine the projct whose configuration we will use. If there is only a single project in the solution we can go with that, if there are multiple projects then at least one of the must be set as startup project, but only the configuration of the first one will be used.<br />If we found the projects, we use the GetArgumentsForDebug function (see details later) to read the application pool name from the configuration.<br />Finally we call the AttachToAppPool function (see details later) to attach or debugger to the process of the application pool.</p>
<p></span><span style="font-size:10pt;font-family:&#39;Courier New&#39;;">Public Sub AttachMacro()</p>
<p>Try<br /><span style="">&nbsp;&nbsp;&nbsp; </span>&#39; get the startup project first<br /><span style="">&nbsp;&nbsp;&nbsp; </span>Dim project As Project<br /><span style="">&nbsp;</span><span style="">&nbsp;&nbsp; </span>Dim solutionBuild As SolutionBuild = DTE.Solution.SolutionBuild<br /><span style="">&nbsp;&nbsp;&nbsp; </span>Dim startUpProjs As Array = solutionBuild.StartupProjects<br /><span style="">&nbsp;&nbsp;&nbsp; </span>Dim projName As String</p>
<p><span style="">&nbsp;&nbsp;&nbsp; </span>If startUpProjs.Length = 0 Then<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>If DTE.Solution.Projects.Count = 1 Then<br /><span style="">&nbsp;&nbsp;&nbsp; </span>project = DTE.Solution.Projects.Item(1)<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Else<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;</span>MsgBox(&quot;There is no startup project and solution contains multiple project!&quot;, MsgBoxStyle.Exclamation, &quot;Alert&quot;)<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;</span>Exit Sub<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>End If<br /><span style="">&nbsp;&nbsp;&nbsp; </span>Else<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>projName = solutionBuild.StartupProjects(0)<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>project = GetProjectByName(projName)<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>If project Is Nothing Then<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;</span>MsgBox(String.Format(&quot;Startup project &#39;{0}&#39; not found by name!&quot;, projName), MsgBoxStyle.Exclamation, &quot;Alert&quot;)<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;</span>Exit Sub<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>End If<br /><span style="">&nbsp;&nbsp;&nbsp; </span>End If</p>
<p><span style="">&nbsp;&nbsp;&nbsp; </span>Dim appPoolName As String = GetArgumentsForDebug(project)</p>
<p><span style="">&nbsp;&nbsp;&nbsp; </span>If String.IsNullOrEmpty(appPoolName) Then<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>MsgBox(String.Format(&quot;Command line arguments property is not set for stratup project &#39;{0}&#39;, debug mode!&quot;, projName), MsgBoxStyle.Exclamation, &quot;Alert&quot;)<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Exit Sub<br /><span style="">&nbsp;&nbsp;&nbsp; </span>End If</p>
<p><span style="">&nbsp;&nbsp;&nbsp; </span>Dim processFound As Boolean = AttachToAppPool(appPoolName)</p>
<p><span style="">&nbsp;&nbsp;&nbsp; </span>If Not processFound Then<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>MsgBox(String.Format(&quot;No worker process found for application pool called &#39;{0}&#39;!&quot;, appPoolName), MsgBoxStyle.Exclamation, &quot;Alert&quot;)<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Exit Sub<br /><span style="">&nbsp;&nbsp;&nbsp; </span>End If</p>
<p>Catch ex As System.Exception<br /><span style="">&nbsp;&nbsp;&nbsp; </span>MsgBox(ex.Message)<br />End Try</p>
<p>End Sub<br /></span><span style="font-size:10pt;font-family:&#39;Arial&#39;,&#39;sans-serif&#39;;"></p>
<p>The GetProjectByName function is a simple helper method to get the project object using the name of the startup project.<br /></span><span style="font-size:10pt;font-family:&#39;Courier New&#39;;"><br />Private Function GetProjectByName(ByVal projectName As String) As Project</p>
<p>Dim result As Project = Nothing<br />For Each project As Project In DTE.Solution.Projects<br /><span style="">&nbsp;&nbsp;&nbsp; </span>If project.UniqueName = projectName Then<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>result = project<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Exit For<br /><span style="">&nbsp;&nbsp;&nbsp; </span>End If<br />Next</p>
<p><span style="">GetProjectByName = </span>result</p>
<p>End Function</p>
<p></span><span style="font-size:10pt;font-family:&#39;Arial&#39;,&#39;sans-serif&#39;;"><br />In the GetArgumentsForDebug function we read the Command line arguments value that is stored in the StartArguments parameter from the debug config of the specifed project.<br /></span><span style="font-size:10pt;font-family:&#39;Courier New&#39;;"><br />Private Function GetArgumentsForDebug(ByVal project As Project) As String</p>
<p>Dim configuration As EnvDTE.Configuration<br />GetArgumentsForDebug = String.Empty</p>
<p>For Each configuration In project.ConfigurationManager<br /><span style="">&nbsp;&nbsp;&nbsp; </span>If configuration.ConfigurationName = &quot;Debug&quot; Then<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Dim startArgsObj As Object = configuration.Properties.Item(&quot;StartArguments&quot;)<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>If Not startArgsObj Is Nothing Then<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;</span>GetArgumentsForDebug = CType(startArgsObj.Value, String)<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>End If<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Exit Function<br /><span style="">&nbsp;&nbsp;&nbsp; </span>End If<br />Next</p>
<p>End Function</p>
<p></span><span style="font-size:10pt;font-family:&#39;Arial&#39;,&#39;sans-serif&#39;;">An interesting part of the macro is the GetProcessIdByAppPoolName function. In this function we use WMI (<b style="mso-bidi-font-weight:normal;">IMPORTANT:</b> don&rsquo;t forget to reference the System.Management assembly!) to get the list of all w3wp.exe processes, and select the one that belongs to the specified application pool. The ID of the process is returned.<br />In the comparison we use the GetAppPoolNameFromCommandLine function (see later), that receives the CommandLine property of the process, that looks like this for a w3wp.exe process:<br /></span><span style="font-size:10pt;font-family:&#39;Courier New&#39;;">c:windowssystem32inetsrvw3wp.exe -a \.pipeiisipm5f3cda83-745a-423a-88b2-103a2f632200 -ap &quot;MyAppPool&quot;<br /></span><span style="font-size:10pt;font-family:&#39;Arial&#39;,&#39;sans-serif&#39;;">You can see that the name of the application pool is at the end of the string.<br /></span><span style="font-size:10pt;font-family:&#39;Courier New&#39;;"><br />Private Function GetProcessIdByAppPoolName(ByVal appPoolName As String) As Long</p>
<p>GetProcessIdByAppPoolName = -1<br />Dim scope As ManagementScope = New ManagementScope(&quot;\localhost<br />
ootcimv2&quot;)</p>
<p>Dim searcher As ManagementObjectSearcher = New ManagementObjectSearcher(&quot;select * from Win32_Process where Name=&#39;w3wp.exe&#39;&quot;)<br />searcher.Scope = scope</p>
<p>For Each process As ManagementObject In searcher.Get()<br /><span style="">&nbsp;&nbsp;&nbsp; </span>Dim commandLine As String = process.GetPropertyValue(&quot;CommandLine&quot;)<br /><span style="">&nbsp;&nbsp;&nbsp; </span>If GetAppPoolNameFromCommandLine(commandLine).ToUpper() = appPoolName.ToUpper() Then<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>GetProcessIdByAppPoolName = process.GetPropertyValue(&quot;ProcessId&quot;)<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Exit For<br /><span style="">&nbsp;&nbsp;&nbsp; </span>End If<br />Next</p>
<p>End Function</p>
<p></span><span style="font-size:10pt;font-family:&#39;Arial&#39;,&#39;sans-serif&#39;;">In the GetAppPoolNameFromCommandLine function we use a simple regular expression to get the name of the application pool from the CommandLine string.<br /></span><span style="font-size:10pt;font-family:&#39;Courier New&#39;;"><br />Private Function GetAppPoolNameFromCommandLine(ByVal commandLine As String) As String</p>
<p>GetAppPoolNameFromCommandLine = String.Empty<br />Dim re As Regex = New Regex(&quot;-ap &quot;&quot;(.+)&quot;&quot;&quot;, RegexOptions.IgnoreCase)<br />Dim matches As MatchCollection = re.Matches(commandLine)<br />If matches.Count = 1 Then<br /><span style="">&nbsp;&nbsp;&nbsp; </span>If matches.Item(0).Groups.Count &gt; 1 Then<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>GetAppPoolNameFromCommandLine = matches.Item(0).Groups(1).Value<br /><span style="">&nbsp;&nbsp;&nbsp; </span>End If<br />End If</p>
<p>End Function</p>
<p></span><span style="font-size:10pt;font-family:&#39;Arial&#39;,&#39;sans-serif&#39;;">In the AttachToAppPool function we attach the debugger to the process having the same process ID that we determined earlier.<br /></span><span style="font-size:10pt;font-family:&#39;Courier New&#39;;"><br />Private Function AttachToAppPool(ByVal appPoolName As String) As Boolean</p>
<p>Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger<br />Dim trans As EnvDTE80.Transport = dbg2.Transports.Item(&quot;Default&quot;)<br />Dim dbgeng(2) As EnvDTE80.Engine<br />dbgeng(0) = trans.Engines.Item(&quot;T-SQL&quot;)<br />dbgeng(1) = trans.Engines.Item(&quot;Managed&quot;)</p>
<p>AttachToAppPool = False<br />For Each process As EnvDTE80.Process2 In dbg2.LocalProcesses<br /><span style="">&nbsp;&nbsp;&nbsp; </span>If process.ProcessID = GetProcessIdByAppPoolName(appPoolName) Then<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>process.Attach()<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>AttachToAppPool = True<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Exit For<br /><span style="">&nbsp;&nbsp;&nbsp; </span>End If<br />Next</p>
<p>End Function</p>
<p></span><span style="font-size:10pt;font-family:&#39;Arial&#39;,&#39;sans-serif&#39;;">To make things even more comfortable it is the best to assign a keyboard shortcut to the macro using the Visual Studio Tools/Options&#8230; menu item as shown on the screenshot below:</p>
<p></span><span style="font-size:10pt;font-family:&#39;Arial&#39;,&#39;sans-serif&#39;;"><a href="/oldweblogfiles/pholpar.AttachDebugger/AttachMacroShortcut.PNG"><img border="0" src="/oldweblogfiles/pholpar.AttachDebugger/AttachMacroShortcut.PNG" alt="  " /></a></span></div>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/pholpar/2009/06/12/i-got-tired-of-attaching-debugger-to-w3wp-exe-and-you/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Columns missing when using the Lists.GetListItems SharePoint webservice</title>
		<link>http://vspug.com/pholpar/2009/06/10/columns-missing-when-using-the-lists-getlistitems-sharepoint-webservice/</link>
		<comments>http://vspug.com/pholpar/2009/06/10/columns-missing-when-using-the-lists-getlistitems-sharepoint-webservice/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 22:23:00 +0000</pubDate>
		<dc:creator>pholpar</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[More people complained about that the result of the Lists.GetListItems method call does not contain the empty fields, so the resulting XML cannot be load into a DataSet:http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/95855246-b8f8-4dda-897a-c4480cc74044/#0a2d42ed-7365-413c-a12f-ccbf95025c12http://www.tech-archive.net/Archive/SharePoint/microsoft.public.sharepoint.portalserver.development/2006-09/msg00056.html
A dirty workaround for that issue may be to adding the missing attributes to the XML from code before trying to load into the DataSet.
In the following code [...]]]></description>
			<content:encoded><![CDATA[<p>More people complained about that the result of the Lists.GetListItems method call does not contain the empty fields, so the resulting XML cannot be load into a DataSet:<br /><a href="http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/95855246-b8f8-4dda-897a-c4480cc74044/#0a2d42ed-7365-413c-a12f-ccbf95025c12">http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/95855246-b8f8-4dda-897a-c4480cc74044/#0a2d42ed-7365-413c-a12f-ccbf95025c12</a><br /><a href="http://www.tech-archive.net/Archive/SharePoint/microsoft.public.sharepoint.portalserver.development/2006-09/msg00056.html">http://www.tech-archive.net/Archive/SharePoint/microsoft.public.sharepoint.portalserver.development/2006-09/msg00056.html</a></p>
<p>A dirty workaround for that issue may be to adding the missing attributes to the XML from code before trying to load into the DataSet.</p>
<p>In the following code I illustrate this approach. In this code I first get the columns of the default view of the list using the List.GetListAndView method, then retrive the data using the Lists.GetListItems method, iterate through all the rows and columns, and if an attribute is missing for a column, add an empty attribute.</p>
<p>String listName = &quot;YourListName&quot;;</p>
<p>listService.Credentials = new NetworkCredential(&quot;user&quot;, &quot;password&quot;, &quot;domain&quot;);</p>
<p>XmlNamespaceManager nsmgr;</p>
<p>// get info about the default view<br />// the 2nd parameter is null -&gt; it is the default view<br />XmlNode listView = listService.GetListAndView(listName, null);<br />nsmgr&nbsp; = new XmlNamespaceManager(listView.OwnerDocument.NameTable);<br />nsmgr.AddNamespace(&quot;a&quot;, &quot;<a href="http://schemas.microsoft.com/sharepoint/soap/">http://schemas.microsoft.com/sharepoint/soap/</a>&quot;);</p>
<p>List&lt;String&gt; fieldNames = new List&lt;string&gt;();<br />foreach (XmlNode field in listView.SelectNodes(&quot;a:List/a:Fields/a:Field&quot;, nsmgr))<br />{<br />&nbsp;&nbsp;&nbsp; XmlAttribute attr = field.Attributes[&quot;Name&quot;];<br />&nbsp;&nbsp;&nbsp; // it should not be null, but we check it<br />&nbsp;&nbsp;&nbsp; if (attr != null)<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // we store all fields in a collection for later use<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fieldNames.Add(attr.Value);<br />&nbsp;&nbsp;&nbsp; }<br />}</p>
<p>// get data from list<br />XmlNode items = listService.GetListItems(listName, null, null, null, null, null, null);</p>
<p>nsmgr = new XmlNamespaceManager(items.OwnerDocument.NameTable);<br />nsmgr.AddNamespace(&quot;z&quot;, &quot;#RowsetSchema&quot;);<br />nsmgr.AddNamespace(&quot;rs&quot;, &quot;urn:schemas-microsoft-com:rowset&quot;);</p>
<p>XmlNodeList itemNodeList = items.SelectNodes(&quot;rs:data/z:row&quot;, nsmgr);</p>
<p>foreach(XmlNode itemNode in itemNodeList)<br />{<br />&nbsp;&nbsp;&nbsp; foreach (String fieldName in fieldNames)<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String wsFieldName = &quot;ows_&quot; + fieldName;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XmlAttribute attr = itemNode.Attributes[wsFieldName];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // if the attribute is missing, we should add it<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (attr == null)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; attr = itemNode.OwnerDocument.CreateAttribute(wsFieldName);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; itemNode.Attributes.Append(attr);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; }<br />}</p>
<p>DataSet listDataSet = new DataSet();</p>
<p>// read the result into a data set<br />XmlTextReader readerListDataSet = new XmlTextReader(items.OuterXml, XmlNodeType.Document, null);<br />listDataSet.ReadXml(readerListDataSet);</p>
<p>After this kind of preparation of XML it can be loaded into the DataSet.</p>
<p>You should know that this approach may not scale and perform well in case of a large amount of data, and I consider it a dirty workaround, but I don&#39;t know currently other solution for this request.</p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/pholpar/2009/06/10/columns-missing-when-using-the-lists-getlistitems-sharepoint-webservice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to deploy a custom field with custom properties from a feature</title>
		<link>http://vspug.com/pholpar/2008/08/12/how-to-deploy-a-custom-field-with-custom-properties-from-a-feature/</link>
		<comments>http://vspug.com/pholpar/2008/08/12/how-to-deploy-a-custom-field-with-custom-properties-from-a-feature/#comments</comments>
		<pubDate>Tue, 12 Aug 2008 21:46:00 +0000</pubDate>
		<dc:creator>pholpar</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[When MOSS 2007 was still in beta and features and custom fields were new areas to discover we created the classic regular expression field type too, just to play with and learn the new technology.
Our implementation SPFieldRegEx was inherited from the Text type and had three custom properties defined in the field type definition XML: [...]]]></description>
			<content:encoded><![CDATA[<p><span style="mso-ansi-language:EN-US;"><font><font>When MOSS 2007 was still in beta and features and custom fields were new areas to discover we created the classic regular expression field type too, just to play with and learn the new technology.</font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><font></font></font></span><span style="mso-ansi-language:EN-US;"><font><font>Our implementation <b style="mso-bidi-font-weight:normal;">SPFieldRegEx</b> was inherited from the <b style="mso-bidi-font-weight:normal;">Text</b> type and had three custom properties defined in the field type definition XML:</font></font></span> </p>
<div style="BORDER-RIGHT:#b6dde8 1.5pt solid;PADDING-RIGHT:4pt;BORDER-TOP:#b6dde8 1.5pt solid;PADDING-LEFT:4pt;BACKGROUND:#daeef3;PADDING-BOTTOM:4pt;BORDER-LEFT:#b6dde8 1.5pt solid;PADDING-TOP:4pt;BORDER-BOTTOM:#b6dde8 1.5pt solid;mso-element:para-border-div;mso-border-themecolor:accent5;mso-border-themetint:102;mso-background-themecolor:accent5;mso-background-themetint:51;"><span style="mso-ansi-language:HU;"><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;PropertySchema&gt;<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;Fields&gt;<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;Field Name=&quot;RegEx&quot; DisplayName=&quot;Regular Expression&quot; MaxLength=&quot;255&quot; DisplaySize=&quot;15&quot; Type=&quot;Text&quot;&gt;<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;/Field&gt;<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;Field Name=&quot;MaxLen&quot; DisplayName=&quot;Maximum length&quot; MaxLength=&quot;3&quot; DisplaySize=&quot;3&quot; Type=&quot;Integer&quot;&gt;<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;Default&gt;255&lt;/Default&gt;<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;/Field&gt;<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;Field Name=&quot;ErrMsg&quot; DisplayName=&quot;Validation message&quot; MaxLength=&quot;255&quot; DisplaySize=&quot;30&quot; Type=&quot;Text&quot;&gt;<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;Default&gt;The value does not match the regular expression&lt;/Default&gt;<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;/Field&gt;<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;/Fields&gt;<br /><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;/PropertySchema&gt;</font></span></div>
<p><span style="mso-ansi-language:EN-US;"><font><font>The <b style="mso-bidi-font-weight:normal;">RegEx</b> property stores the regular expression pattern, the <b style="mso-bidi-font-weight:normal;">MaxLen</b> controls the maximal length of the field content and finally, the <b style="mso-bidi-font-weight:normal;">ErrMsg</b> holds the validation message to be displayed when the input text does not match with the regular expression.</font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"></span><span style="mso-ansi-language:EN-US;"><font><font>There is nothing interesting in that up to this point, but if you would like to deploy this custom field using a feature setting custom values to the properties you might encounter some difficulty.</font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><font></font></font></span><span style="mso-ansi-language:EN-US;"><font><font>Since I haven&#39;t found that documented neither in the WSS SDK nor on developer blogs in the past years, I decided to share my experience.</font></font></span><span style="mso-ansi-language:EN-US;"><font><font></font></font></span><span style="mso-ansi-language:EN-US;"><font><font>If you create your feature definition for the field as you do normally with the built in field types, the result is the following XML:</font></font></span> </p>
<div style="BORDER-RIGHT:#b6dde8 1.5pt solid;PADDING-RIGHT:4pt;BORDER-TOP:#b6dde8 1.5pt solid;PADDING-LEFT:4pt;BACKGROUND:#daeef3;PADDING-BOTTOM:4pt;BORDER-LEFT:#b6dde8 1.5pt solid;PADDING-TOP:4pt;BORDER-BOTTOM:#b6dde8 1.5pt solid;mso-element:para-border-div;mso-border-themecolor:accent5;mso-border-themetint:102;mso-background-themecolor:accent5;mso-background-themetint:51;">
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;<br />&lt;Elements xmlns=&quot;http://schemas.microsoft.com/sharepoint/&quot;&gt;<br /><span style="">&nbsp; </span>&lt;Field ID=&quot;{54634385-A8AC-4898-BF24-E533EB23444F}&quot; Name=&quot;RegExField&quot; DisplayName=&quot;RegExField&quot; StaticName=&quot;RegExField&quot; Group=&quot;Grepton Fields&quot; Type=&quot;SPFieldRegEx&quot; Sealed=&quot;FALSE&quot; AllowDeletion=&quot;TRUE&quot; SourceID=&quot;http://schemas.microsoft.com/sharepoint/v3/fields&quot; Description=&quot;This is the RegEx field&quot; RegEx=&quot;[0-9]&quot; MaxLen=&quot;20&quot; ErrMsg=&quot;Error!&quot;/&gt;<br />&lt;/Elements&gt;</font></span></p>
</div>
<p><span style="mso-ansi-language:EN-US;"><font><font>But if you try to install the feature, you get the following error:</font></font></span> </p>
<div style="BORDER-RIGHT:#b6dde8 1.5pt solid;PADDING-RIGHT:4pt;BORDER-TOP:#b6dde8 1.5pt solid;PADDING-LEFT:4pt;BACKGROUND:#daeef3;PADDING-BOTTOM:4pt;BORDER-LEFT:#b6dde8 1.5pt solid;PADDING-TOP:4pt;BORDER-BOTTOM:#b6dde8 1.5pt solid;mso-element:para-border-div;mso-border-themecolor:accent5;mso-border-themetint:102;mso-background-themecolor:accent5;mso-background-themetint:51;">
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas">Feature definition with Id 6fd6ca04-3ac3-490f-b22f-4461a2253001 failed validation, file &#39;feature_definition2.xml&#39;, line 5, character 299:</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas">The &#39;RegEx&#39; attribute is not allowed.</font></span></p>
</div>
<p><span style="mso-ansi-language:EN-US;"><font><font>If you remove the <b style="mso-bidi-font-weight:normal;">RegEx</b> attribute, the same error message appears with <b style="mso-bidi-font-weight:normal;">MaxLen</b>, if you remove that too, the <b style="mso-bidi-font-weight:normal;">ErrMsg</b> causes problem.</font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><font></font></font></span><span style="mso-ansi-language:EN-US;"><font><font>So what to do to make this attributes allowed?</font></font></span><span style="mso-ansi-language:EN-US;"><font><font></font></font></span><span style="mso-ansi-language:EN-US;"><font><font>The schema of the features is defined in the <b style="mso-bidi-font-weight:normal;">wss.xsd</b>. Now the most important part for us is the <b style="mso-bidi-font-weight:normal;">FieldDefinition</b> complexType that is responsible &#8211; what a surprise! &#8211; for describing the format of the field definitions in the features. Besides other things it contains the list of the allowed attributes.</font></font></span> </p>
<div style="BORDER-RIGHT:#b6dde8 1.5pt solid;PADDING-RIGHT:4pt;BORDER-TOP:#b6dde8 1.5pt solid;PADDING-LEFT:4pt;BACKGROUND:#daeef3;PADDING-BOTTOM:4pt;BORDER-LEFT:#b6dde8 1.5pt solid;PADDING-TOP:4pt;BORDER-BOTTOM:#b6dde8 1.5pt solid;mso-element:para-border-div;mso-border-themecolor:accent5;mso-border-themetint:102;mso-background-themecolor:accent5;mso-background-themetint:51;">
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp; </span>&lt;xs:complexType name=&quot;FieldDefinition&quot; mixed=&quot;true&quot;&gt;<br />&#8230;<br /><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;xs:attribute name=&quot;Decimals&quot; type=&quot;xs:int&quot; /&gt;<br /><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;xs:attribute name=&quot;Description&quot; type=&quot;xs:string&quot; /&gt;<br />&#8230;<br /><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;xs:attribute name=&quot;DisplayName&quot; type=&quot;xs:string&quot; /&gt;<br />&#8230;<br /><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;xs:attribute name=&quot;FillInChoice&quot; type=&quot;TRUEFALSE&quot; /&gt;<br />&#8230;<br /><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;xs:attribute name=&quot;Hidden&quot; type=&quot;TRUEFALSE&quot; /&gt;<br />&#8230;<br /><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;xs:attribute name=&quot;Max&quot; type=&quot;xs:float&quot; /&gt;<br /><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;xs:attribute name=&quot;Min&quot; type=&quot;xs:string&quot; /&gt;<br />&#8230;<br /><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;xs:attribute name=&quot;Name&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/&gt;<br />&#8230;<br /><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;xs:attribute name=&quot;ReadOnly&quot; type=&quot;TRUEFALSE&quot; /&gt;<br />&#8230;<br /><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;xs:attribute name=&quot;Required&quot; type=&quot;TRUEFALSE&quot; /&gt;<br />&#8230;<br /><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;xs:attribute name=&quot;Title&quot; type=&quot;xs:string&quot; /&gt;<br /><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;xs:attribute name=&quot;Type&quot; type=&quot;xs:string&quot; use=&quot;required&quot; /&gt;<br />&#8230;<br /><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;xs:attribute name=&quot;ID&quot; type=&quot;UniqueIdentifier&quot; /&gt;<br /><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;xs:attribute name=&quot;Group&quot; type=&quot;xs:string&quot; /&gt;<br /><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;xs:attribute name=&quot;MaxLength&quot; type=&quot;xs:int&quot; /&gt;<br /><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;xs:attribute name=&quot;SourceID&quot; type=&quot;xs:string&quot; /&gt;<br /><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;xs:attribute name=&quot;StaticName&quot; type=&quot;xs:string&quot; /&gt;<br />&#8230;<br /><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;xs:anyAttribute namespace=&quot;##other&quot; processContents=&quot;lax&quot; /&gt;<br /><span style="">&nbsp; </span>&lt;/xs:complexType&gt;</p>
<p></font></span></p>
</div>
<p><span style="mso-ansi-language:EN-US;"><font><font>The fragment above contains only the most widely used attributes for example.</font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><font></font></font></span><span style="mso-ansi-language:EN-US;"><font><font>One quick and dirty solution would be to include our custom attributes in the XSD schema but this probably wouldn&#39;t be a supported method. Fortunately in this case MS has left the back door open: if you check the last attribute in the schema, it is <b style="mso-bidi-font-weight:normal;"><a href="http://msdn.microsoft.com/en-us/library/ms256443.aspx"><font color="#800080">anyAttribute</font></a></b> with namespace <b style="mso-bidi-font-weight:normal;">##other</b>, meaning that you can inject your own attributes in the XML files using your own namespace.</p>
<p></font></font></span><span style="mso-ansi-language:EN-US;"><font><font></font></font></span><span style="mso-ansi-language:EN-US;"><font><font>After a minor modification in the feature definition XML (highlighted below) the XML was passed the schema check and our custom field feature was installed successfully.</font></font></span> </p>
<div style="BORDER-RIGHT:#b6dde8 1.5pt solid;PADDING-RIGHT:4pt;BORDER-TOP:#b6dde8 1.5pt solid;PADDING-LEFT:4pt;BACKGROUND:#daeef3;PADDING-BOTTOM:4pt;BORDER-LEFT:#b6dde8 1.5pt solid;PADDING-TOP:4pt;BORDER-BOTTOM:#b6dde8 1.5pt solid;mso-element:para-border-div;mso-border-themecolor:accent5;mso-border-themetint:102;mso-background-themecolor:accent5;mso-background-themetint:51;">
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;<br />&lt;Elements xmlns=&quot;http://schemas.microsoft.com/sharepoint/&quot; <b style="mso-bidi-font-weight:normal;"><span style="COLOR:#c00000;">xmlns:grp=&quot;http://schemas.grepton.com/sharepoint/&quot;</span></b>&gt;<br /><span style="">&nbsp; </span>&lt;Field ID=&quot;{54634385-A8AC-4898-BF24-E533EB23444F}&quot; Name=&quot;RegExField&quot; DisplayName=&quot;RegExField&quot; StaticName=&quot;RegExField&quot; Group=&quot;Grepton Fields&quot; Type=&quot;SPFieldRegEx&quot; Sealed=&quot;FALSE&quot; AllowDeletion=&quot;TRUE&quot; SourceID=&quot;http://schemas.microsoft.com/sharepoint/v3/fields&quot; Description=&quot;This is the RegEx field&quot; <b style="mso-bidi-font-weight:normal;"><span style="COLOR:#c00000;">grp:</span></b>RegEx=&quot;[0-9]&quot; <b style="mso-bidi-font-weight:normal;"><span style="COLOR:#c00000;">grp:</span></b>MaxLen=&quot;20&quot; <b style="mso-bidi-font-weight:normal;"><span style="COLOR:#c00000;">grp:</span></b>ErrMsg=&quot;Error!&quot;/&gt;<br />&lt;/Elements&gt;</font></span></p>
</div>
<p><span style="mso-ansi-language:EN-US;"><font>&nbsp;</font></span></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/pholpar/2008/08/12/how-to-deploy-a-custom-field-with-custom-properties-from-a-feature/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Negative item count in document libraries</title>
		<link>http://vspug.com/pholpar/2008/03/14/negative-item-count-in-document-libraries/</link>
		<comments>http://vspug.com/pholpar/2008/03/14/negative-item-count-in-document-libraries/#comments</comments>
		<pubDate>Fri, 14 Mar 2008 21:03:00 +0000</pubDate>
		<dc:creator>pholpar</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[
A few days ago we received a complaint from one of our customers. They found that after deleting all documents from it, a SharePoint document library that serves as the base of a custom application shows negative item count on the All Site Content page.
We checked where this value comes from and found it is [...]]]></description>
			<content:encoded><![CDATA[<p><span><font></p>
<p style="MARGIN:3pt 0cm;"><span>A few days ago we received a complaint from one of our customers. They found that after deleting all documents from it, a SharePoint document library that serves as the base of a custom application shows negative item count on the </span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">All Site Content</font></strong></span></span><span> page.</span></p>
<p style="MARGIN:3pt 0cm;">We checked where this value comes from and found it is the </font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">ItemCount</font></strong></span></span><span><font> property of the </font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">SPList</font></strong></span></span><span><font> object.</font></span></p>
<p style="MARGIN:3pt 0cm;"><span style="mso-ansi-language:HU;mso-fareast-language:HU;"></span></p>
<p style="MARGIN:3pt 0cm;"><span><font>An additional side effect of this strange behavior is that the indexing fails because it cannot cast the negative value to an unsigned integer (</font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">UInt32</font></strong></span></span><span><font>).</font></span></p>
<p style="MARGIN:3pt 0cm;"><span style="mso-ansi-language:HU;mso-fareast-language:HU;"></span></p>
<p><span><font></font></span></p>
<p style="MARGIN:3pt 0cm;"><span><font>We could reproduce the behavior using the following code. It assumes that the address of your site is your site is </font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">http://moss/site</font></strong></span></span><span><font> and the name of the document library is </font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">CopyTest</font></strong></span></span><span><font>. The code creates a folder and subfolders, copies it using the </font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">CopyTo()</font></strong></span></span><span><font> method of </font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">SPFolder</font></strong></span></span><span><font> class, and finally deletes the folders.</font></span></p>
<p><span><font>&nbsp;</font></span> </p>
<div style="BORDER-RIGHT:#b6dde8 1.5pt solid;PADDING-RIGHT:4pt;BORDER-TOP:#b6dde8 1.5pt solid;PADDING-LEFT:4pt;BACKGROUND:#daeef3;PADDING-BOTTOM:4pt;BORDER-LEFT:#b6dde8 1.5pt solid;PADDING-TOP:4pt;BORDER-BOTTOM:#b6dde8 1.5pt solid;mso-element:para-border-div;mso-border-themecolor:accent5;mso-border-themetint:102;mso-background-themecolor:accent5;mso-background-themetint:51;">
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>string siteUrl = &quot;http://moss/site&quot;;</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>using (SPSite site = new SPSite(siteUrl))</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>using (_web = site.OpenWeb())</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>SPList list = _web.Lists[&quot;CopyTest&quot;];</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;Items.Count:{0}, ItemCount:{1}&quot;, list.Items.Count, list.ItemCount);</font></span></p>
<p><span><font face="Consolas">&nbsp;</font></span> </p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;Creating 1.0 folder &#8230; &quot;);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>SPFolder rootFolder = _web.GetFolder(&quot;/CopyTest&quot;);</font></span></p>
<p><span><font face="Consolas">&nbsp;</font></span> </p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>SPFolder version1Folder = rootFolder.SubFolders.Add(&quot;/CopyTest/1.0&quot;);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>version1Folder.Update();</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>list.Update();</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;OK&quot;);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;Items.Count:{0}, ItemCount:{1}&quot;, list.Items.Count, list.ItemCount);</font></span></p>
<p><span><font face="Consolas">&nbsp;</font></span> </p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;Creating Test1 in 1.0 folder &#8230; &quot;);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>SPFolder testFolder = version1Folder.SubFolders.Add(version1Folder.Url + &quot;/Test1&quot;);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>testFolder.Update();</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>list.Update();</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;OK&quot;);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;Items.Count: {0}&quot;, list.Items.Count);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;ItemCount: {0}&quot;, list.ItemCount);</font></span></p>
<p><span><font face="Consolas">&nbsp;</font></span> </p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;Creating Test1.1 in Test1 folder &#8230; &quot;);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>SPFolder test2Folder = version1Folder.SubFolders.Add(version1Folder.Url + &quot;/Test1/Test1.1&quot;);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>test2Folder.Update();</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>list.Update();</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;OK&quot;);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;Items.Count: {0}&quot;, list.Items.Count);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;ItemCount: {0}&quot;, list.ItemCount);</font></span></p>
<p><span><font face="Consolas">&nbsp;</font></span> </p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;Creating Test2 in 1.0 folder &#8230; &quot;);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>SPFolder test3Folder = version1Folder.SubFolders.Add(version1Folder.Url + &quot;/Test2&quot;);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>test3Folder.Update();</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>list.Update();</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;OK&quot;);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp; </span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>Console.WriteLine(&quot;Items.Count: {0}&quot;, list.Items.Count);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;ItemCount: {0}&quot;, list.ItemCount);</font></span></p>
<p><span><font face="Consolas">&nbsp;</font></span> </p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;Creating 2.0 folder in the root &#8230; &quot;);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>SPFolder version2Folder = rootFolder.SubFolders.Add(&quot;/CopyTest/2.0&quot;);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>version2Folder.Update();</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>list.Update();</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;OK&quot;);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;Items.Count:{0}, ItemCount:{1}&quot;, list.Items.Count, list.ItemCount);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><span style=""><font face="Consolas">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;Copy 1.0 items to 2.0&quot;);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><span style=""><font face="Consolas">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>foreach (SPFolder subFolder in version1Folder.SubFolders)</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;Copy {0} folder &#8230; &quot;, subFolder.Name);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>subFolder.CopyTo(version2Folder.Url + &quot;/&quot; + subFolder.Name);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>SPFolder folder = _web.GetFolder(version2Folder.Url + &quot;/&quot; + subFolder.Name);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>if(folder.Exists)</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;Folder exists, url is: {0}&quot;, folder.ServerRelativeUrl);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>folder.Update();</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>list.Update();</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;OK&quot;);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;Items.Count:{0}, ItemCount:{1}&quot;, list.Items.Count, list.ItemCount);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><span style=""><font face="Consolas">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;Deleting 1.0 folder &#8230; &quot;);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>SPFolder deleteFolder = _web.GetFolder(&quot;/CopyTest/1.0&quot;);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>if (deleteFolder.Exists)</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>deleteFolder.Delete();</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>list.Update();</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;OK&quot;);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;Deleting 2.0 folder &#8230; &quot;);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>deleteFolder = _web.GetFolder(&quot;/CopyTest/2.0&quot;);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>if (deleteFolder.Exists)</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;</span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>deleteFolder.Delete();</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>list.Update();</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;OK&quot;);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</font></span></p>
<p><span><font face="Consolas">&nbsp;</font></span> </p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Console.WriteLine(&quot;SPList.ItemCount = {0}&quot;, list.ItemCount);</font></span></p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</font></span></p>
<p><span><font face="Consolas">&nbsp;</font></span> </p>
<p class="ProgramText" style="MARGIN:0cm 0cm 0pt;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</font></span></p>
</div>
<p style="MARGIN:3pt 0cm;"><span><font>We escalated the issue to MS support and waiting for a resolution now.</font></span></p>
<p><span></p>
<p style="MARGIN:3pt 0cm;"><span><font><font>I should note that there is an interesting blog post about the relation of<span style="">&nbsp; </span></font></font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">SPList.ItemCount</font></strong></span></span><span><font> and </font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">SPList.Items.Count</font></strong></span></span><span><font> </font><a href="http://planetwilson.blogspot.com/2007/12/itemcount-and-itemscount.html"><font>here</font></a><font><font>. The main point is that if the number of items is changed (for example, by deleting or creating items) in the document libraries, then the value stored int he <span style="">&nbsp;</span></font></font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">ItemCount</font></strong></span></span><span><font> does not changed until </font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">SPList.Update()</font></strong></span></span><span><font> is called. You should be aware of this behavior in your custom applications.</font></span></p>
<p></span></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/pholpar/2008/03/14/negative-item-count-in-document-libraries/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using Month element in DateRangesOverlap can return items not in the specified month</title>
		<link>http://vspug.com/pholpar/2008/03/03/using-month-element-in-daterangesoverlap-can-return-items-not-in-the-specified-month/</link>
		<comments>http://vspug.com/pholpar/2008/03/03/using-month-element-in-daterangesoverlap-can-return-items-not-in-the-specified-month/#comments</comments>
		<pubDate>Mon, 03 Mar 2008 22:21:00 +0000</pubDate>
		<dc:creator>pholpar</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[One can logically think that if you set the CalendarDate property of the SPQuery and apply Month as the Value in the DateRangesOverlap element then the query returns items from the month specified in the CalendarDate property.
For example, using the following code .
SPQuery query = new SPQuery(); 
query.CalendarDate = new DateTime(2008, 3, 1);

. and applying [...]]]></description>
			<content:encoded><![CDATA[<p style="MARGIN:3pt 0cm;"><span><font>One can logically think that if you set the </font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">CalendarDate</font></strong></span></span><span><font> property of the </font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">SPQuery</font></strong></span></span><span><font> and apply </font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">Month</font></strong></span></span><span><font> as the </font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">Value</font></strong></span></span><span><font> in the </font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">DateRangesOverlap</font></strong></span></span><span><font> element then the query returns items from the month specified in the </font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">CalendarDate</font></strong></span></span><span><font> property.</font></span></p>
<p style="MARGIN:3pt 0cm;"><span></span><span><font>For example, using the following code .</font></span></p>
<div style="BORDER-RIGHT:#b6dde8 1.5pt solid;PADDING-RIGHT:4pt;BORDER-TOP:#b6dde8 1.5pt solid;PADDING-LEFT:4pt;BACKGROUND:#daeef3;PADDING-BOTTOM:4pt;BORDER-LEFT:#b6dde8 1.5pt solid;PADDING-TOP:4pt;BORDER-BOTTOM:#b6dde8 1.5pt solid;mso-element:para-border-div;mso-border-themecolor:accent5;mso-border-themetint:102;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas">SPQuery query = new SPQuery();</font></span> </p>
<p class="ProgramText" style="BACKGROUND:#daeef3;MARGIN:0cm 0cm 0pt;mso-background-themecolor:accent5;mso-background-themetint:51;"><span><font face="Consolas">query.CalendarDate = new DateTime(2008, 3, 1);</font></span></p>
</div>
<p style="MARGIN:3pt 0cm;"><span><font>. and applying the following CAML query .</font></span></p>
<div style="BORDER-RIGHT:#b6dde8 1.5pt solid;PADDING-RIGHT:4pt;BORDER-TOP:#b6dde8 1.5pt solid;PADDING-LEFT:4pt;BACKGROUND:#daeef3;PADDING-BOTTOM:4pt;BORDER-LEFT:#b6dde8 1.5pt solid;PADDING-TOP:4pt;BORDER-BOTTOM:#b6dde8 1.5pt solid;mso-element:para-border-div;mso-border-themecolor:accent5;mso-border-themetint:102;mso-background-themecolor:accent5;mso-background-themetint:51;">
<p class="ProgramText" style="MARGIN:0cm 0cm 0pt;"><span><font face="Consolas">&lt;Where&gt;</font></span></p>
<p class="ProgramText" style="MARGIN:0cm 0cm 0pt;"><span><font face="Consolas"><span style="">&nbsp; </span>&lt;DateRangesOverlap&gt;</font></span></p>
<p class="ProgramText" style="MARGIN:0cm 0cm 0pt;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;FieldRef Name=&#39;StartDate&#39; /&gt;</font></span></p>
<p class="ProgramText" style="MARGIN:0cm 0cm 0pt;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;FieldRef Name=&#39;EndDate&#39; /&gt;</font></span></p>
<p class="ProgramText" style="MARGIN:0cm 0cm 0pt;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;Value Type=&#39;DateTime&#39;&gt;</font></span></p>
<p class="ProgramText" style="MARGIN:0cm 0cm 0pt;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;Month /&gt;</font></span></p>
<p class="ProgramText" style="MARGIN:0cm 0cm 0pt;"><span><font face="Consolas"><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;/Value&gt;</font></span></p>
<p class="ProgramText" style="MARGIN:0cm 0cm 0pt;"><span><font face="Consolas"><span style="">&nbsp; </span>&lt;/DateRangesOverlap&gt;</font></span></p>
<p class="ProgramText" style="MARGIN:0cm 0cm 0pt;"><span><font face="Consolas">&lt;/Where&gt;</font></span></p>
</div>
<p style="MARGIN:3pt 0cm;"><span><font>&nbsp;</font></span><span><font>. one can expect that items having overlap with March 2008 will be only returned.</font></span></p>
<p style="MARGIN:3pt 0cm;"><span></span><span><font>I&#39;ve found that it is not exactly so, as elements from the end of February and beginning of April may be also returned. The reason for that I think is the simple fact that these items have overlap with the calendar range of the month view of March 2008 (e.g. 24/02/2008-05/04/2008), as the month calendar view includes the full weeks at the beginning and the end of the month, not only the days between 01/03/2008-31/03/2008.</font></span></p>
<p style="MARGIN:3pt 0cm;"><span></span><span><font>Since </font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">DateRangesOverlap</font></strong></span></span><span><font> is (another) under-documented element of SharePoint and CAML I can&#39;t decide if it is a bug or a feature. Since it is used primarily in the calendar views it seems to be logical that it should return all items that need to be displayed in the month view. So it is probably by design, sad that this fact is not documented.</font></span></p>
<p style="MARGIN:3pt 0cm;"><span></span><span><font>This fact caused a misbehavior (or let&#39;s call it bug) in one of our custom application, so we should return to our original complex CAML query assembled from </font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">Lt</font></strong></span></span><span><font>, </font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">Gt</font></strong></span></span><span><font>, </font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">Leq</font></strong></span></span><span><font>, </font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">Geq</font></strong></span></span><span><font>, composite </font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">And</font></strong></span></span><span><font> and </font></span><span class="ProgramTextChar-Reference"><span style="FONT-SIZE:11pt;"><strong><font face="Consolas">Or</font></strong></span></span><span><font> elements.</font></span></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/pholpar/2008/03/03/using-month-element-in-daterangesoverlap-can-return-items-not-in-the-specified-month/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating Keywords and Best Bets for MOSS Search programmatically</title>
		<link>http://vspug.com/pholpar/2007/11/13/creating-keywords-and-best-bets-for-moss-search-programmatically/</link>
		<comments>http://vspug.com/pholpar/2007/11/13/creating-keywords-and-best-bets-for-moss-search-programmatically/#comments</comments>
		<pubDate>Tue, 13 Nov 2007 21:42:00 +0000</pubDate>
		<dc:creator>pholpar</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[You can administer keywords and best bets on the MOSS admin UI at Search keywords at Site Collection Administration.
Stefan Goáner gave a code snippet about How To: create Keywords and Best Bets for MOSS Search programmatically. A similar code can be found in the very useful SharePoint Server 2007 Presentations: Enterprise Search Deep Dives presentation [...]]]></description>
			<content:encoded><![CDATA[<p style="MARGIN:0cm 0cm 10pt;"><span style="mso-ansi-language:EN-GB;"><font><font>You can administer keywords and best bets on the MOSS admin UI at Search keywords at Site Collection Administration.</font></font></span></p>
<p style="MARGIN:0cm 0cm 10pt;"><span style="mso-ansi-language:EN-GB;"></span><span style="mso-ansi-language:EN-GB;"><font>Stefan Goáner gave a code snippet about <a href="http://blogs.technet.com/stefan_gossner/archive/2007/03/28/how-to-create-keywords-and-best-bets-for-moss-search-programmatically.aspx" target="_blank">How To: create Keywords and Best Bets for MOSS Search programmatically</a></font><font>. A similar code can be found in the very useful SharePoint Server 2007 Presentations: <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=2751D5CD-8690-44B5-AE5C-D2769B227929&amp;displaylang=e" target="_blank">Enterprise Search Deep Dives</a> presentation series, Customizing and Extending Search in Office SharePoint Server 2007.</font></span></p>
<p style="MARGIN:0cm 0cm 10pt;"><span style="mso-ansi-language:EN-GB;"></span><span style="mso-ansi-language:EN-GB;"><font><font>Based on my experiments there might be a little but important problem with this code. When creating the new Keyword instance, you should use DateTime.UtcNow instead of DateTime.Now to enable the Keyword immediately:</font></font></span></p>
<p style="MARGIN:0cm 0cm 10pt;"><span style="mso-ansi-language:EN-GB;"></span><span style="FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-GB;"><font>keywords.AllKeywords.Create(&quot;myKeyword&quot;, DateTime.UtcNow);</font></span></p>
<p style="MARGIN:0cm 0cm 10pt;"><span style="FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-GB;"></span><span style="mso-ansi-language:EN-GB;"><font><font>When you create the keyword through the UI, you can specify only the date part, no hours and minutes. In this case the keyword is created with a start date (StartDate property) 0:00 AM UTC for the specified date. For example, currently our local time is GMT+1, so the start date would be 23:00 PM for the previous day.</font></font></span></p>
<p><span style="mso-ansi-language:EN-GB;"></span><span style="mso-ansi-language:EN-GB;"><font></p>
<p style="MARGIN:0cm 0cm 10pt;"><span style="mso-ansi-language:EN-GB;"><font>When I used the code samples &#8220;as is&#8221;, the keywords were not displayed in the results. After one hour, the repeated search already displayed the keyword matches. When I used the DateTime.UtcNow, the results were displayed immediately. Of course, if your configured time zone is west from the GMT time line, then DateTime.Now should work also, as it is refers to a time in the past if you interpret it as UTC time.</font></span></p>
<p style="MARGIN:0cm 0cm 10pt;"><span style="mso-ansi-language:EN-GB;"></span><span style="mso-ansi-language:EN-GB;"><font>If you try to create a best bet on the UI that refers to an URL already used in an existing best bet you cannot save the new best bet. I found another interesting behaviour of creating keywords and best bets from code. The code that creates the best bets with a common URL but different titles and descriptions will run without errors:</font></span></p>
<p style="MARGIN:0cm 0cm 10pt;"><span style="mso-ansi-language:EN-GB;"></span><span style="FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-GB;"><font>Keyword keyword1= keywords.AllKeywords.Create(&quot;keyword1&quot;, DateTime.UtcNow); <br />BestBet bestBet1 = keyword1.BestBets.Create(&quot;BestBet1&quot;, &quot;Description1&quot;, new Uri(<a href="http://www.company.com/">http://www.company.com</a>));<br />keyword1.Update();<br />Keyword keyword2= keywords.AllKeywords.Create(&quot;keyword2&quot;, DateTime.UtcNow); <br />BestBet bestBet1 = keyword2.BestBets.Create(&quot;BestBet2&quot;, &quot;Description2&quot;, new Uri(<a href="http://www.company.com/">http://www.company.com</a>));<br />keyword2.Update();</font></span></p>
<p><span style="FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-GB;"></span><span style="mso-ansi-language:EN-GB;"><font>In the example above the best bet for keyword2 will refer to the BestBet with title BestBet1 created for keyword1.</font></span></font></span></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/pholpar/2007/11/13/creating-keywords-and-best-bets-for-moss-search-programmatically/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>High Confidence Results in MOSS 2007</title>
		<link>http://vspug.com/pholpar/2007/11/13/high-confidence-results-in-moss-2007/</link>
		<comments>http://vspug.com/pholpar/2007/11/13/high-confidence-results-in-moss-2007/#comments</comments>
		<pubDate>Tue, 13 Nov 2007 16:57:00 +0000</pubDate>
		<dc:creator>pholpar</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[At the MSDN forum I found an interesting question that asks what high confidence results are. After some investigation I think I have the answer for this question. 
First of all, high confidence results are displayed by the Microsoft.Office.Server.Search.WebControls.HighConfidenceWebPart (Microsoft.Office.Server.Search assembly). On the standard search result page (results.aspx) there are two instances of this web [...]]]></description>
			<content:encoded><![CDATA[<p><span style="mso-ansi-language:EN-US;"><font>At the MSDN forum I found an interesting <a title="question" href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2379969&amp;SiteID=1" target="_blank">question</a> </font><font><font>that asks what high confidence results are. </font><span style="mso-ansi-language:EN-US;"><font>After some investigation I think I have the answer for this question.</font></span></font></span><span style="mso-ansi-language:EN-US;"><font></font></span><span style="mso-ansi-language:EN-US;"><font> </p>
<p style="MARGIN:0cm 0cm 10pt;"><span style="mso-ansi-language:EN-US;"><font>First of all, high confidence results are displayed by the Microsoft.Office.Server.Search.WebControls.HighConfidenceWebPart (Microsoft.Office.Server.Search assembly). On the standard search result page (results.aspx) there are two instances of this web part. One is Search High Confidence Results, the other is Search Best Bets. If you check the properties of the HighConfidenceWebPart either by modifying the shared web part, or by using Reflector, you can see that this web part can display keyword matches with best bets and the mysterious high confidence results. By default the Search High Confidence Results web part instance is configured to display the high confidence results and the Search Best Bets web part instance is configured to display keywords and best bets (as one can guess from their name).</font></span></p>
<p style="MARGIN:0cm 0cm 10pt;"><span style="mso-ansi-language:EN-US;"></span><span style="mso-ansi-language:EN-US;"><font>The SDK contains information about that when the Enterprise Search returns the results there is a HighConfidenceResults table that is &#8220;The result set containing high-confidence results&#8221;. Well, it is not very descriptive, is it?</font></span></p>
<p style="MARGIN:0cm 0cm 10pt;"><span style="mso-ansi-language:EN-US;"></span><span style="mso-ansi-language:EN-US;"><font>Let&#39;s see the formatting XSL for the HighConfidenceWebPart. You can check it in the XSL Editor in the Data View Properties section of the tool part. Fortunately, there is a template for the HighConfidenceResults, displayed below:</font></span></p>
<p style="MARGIN:0cm 0cm 10pt;"><span style="mso-ansi-language:EN-US;"></span><font><span style="FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;">&lt;xsl:template match=&quot;All_Results/HighConfidenceResults/Result&quot;&gt;&nbsp;<br /><span style="">&nbsp;</span>&lt;xsl:if test=&quot;$DisplayHC = &#39;True&#39; and $IsFirstPage = &#39;True&#39;&quot; &gt;<br /><span style="">&nbsp; </span>&lt;xsl:variable name=&quot;prefix&quot;&gt;IMNRC(&#39;&lt;/xsl:variable&gt;<br /><span style="">&nbsp; </span>&lt;xsl:variable name=&quot;suffix&quot;&gt;&#39;)&lt;/xsl:variable&gt;<br /><span style="">&nbsp; </span>&lt;xsl:variable name=&quot;url&quot; select=&quot;url&quot;/&gt;<br /><span style="">&nbsp; </span>&lt;xsl:variable name=&quot;id&quot; select=&quot;id&quot;/&gt;<br /><span style="">&nbsp; </span>&lt;xsl:variable name=&quot;pictureurl&quot; select=&quot;highconfidenceimageurl&quot;/&gt;<br /><span style="">&nbsp; </span>&lt;xsl:variable name=&quot;jobtitle&quot; select=&quot;highconfidencedisplayproperty1&quot;/&gt;<br /><span style="">&nbsp; </span>&lt;xsl:variable name=&quot;workphone&quot; select=&quot;highconfidencedisplayproperty2&quot;/&gt;<br /><span style="">&nbsp; </span>&lt;xsl:variable name=&quot;department&quot; select=&quot;highconfidencedisplayproperty3&quot;/&gt;<br /><span style="">&nbsp; </span>&lt;xsl:variable name=&quot;officenumber&quot; select=&quot;highconfidencedisplayproperty4&quot;/&gt;<br /><span style="">&nbsp; </span>&lt;xsl:variable name=&quot;preferredname&quot; select=&quot;highconfidencedisplayproperty5&quot;/&gt;<br /><span style="">&nbsp; </span>&lt;xsl:variable name=&quot;aboutme&quot; select=&quot;highconfidencedisplayproperty8&quot;/&gt;<br /><span style="">&nbsp; </span>&lt;xsl:variable name=&quot;responsibility&quot; select=&quot;highconfidencedisplayproperty9&quot;/&gt;<br /><span style="">&nbsp; </span>&lt;xsl:variable name=&quot;skills&quot; select=&quot;highconfidencedisplayproperty10&quot;/&gt;<br /><span style="">&nbsp; </span>&lt;xsl:variable name=&quot;workemail&quot; select=&quot;highconfidencedisplayproperty11&quot;/&gt;</span></font></p>
<p style="MARGIN:0cm 0cm 10pt;"><font><span style="FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;"></span><span style="mso-ansi-language:EN-US;">You can see, that all of the properties are related to persons. I found that if you search for a person specifying the full name, and there is match, then it is displayed as a high confidence result. In the web part properties you can specify if the title, image, description and other properties should be displayed for a high confidence match. There is a ResultsPerTypeLimit property (&#8220;</span>Maximum matches per High Confidence type &#8220;)<span style="mso-ansi-language:EN-US;"> <span>that similar to the BestBetsLimit property (&#8220;</span></span>Best Bets limit<span style="mso-ansi-language:EN-US;"> &#8221; on the user interface). Based on my experience, the BestBetsLimit works as expected but the ResultsPerTypeLimit seems to have no effect on the displayed results. Checking the default formatting XSL shows that the BestBetsLimit property is used (BBLimit parameter), but the ResultsPerTypeLimit is not used, although it is declared as an XSL parameter with the same name.</span></font></p>
<p style="MARGIN:0cm 0cm 10pt;"><font><span style="mso-ansi-language:EN-US;"></span></font><span style="mso-ansi-language:EN-US;"><font>You should include the following condition in the HighConfidenceResults template (see above) after checking the &quot;$DisplayHC = &#39;True&#39; and $IsFirstPage = &#39;True&#39;&quot; condition:</font></span></p>
<p style="MARGIN:0cm 0cm 10pt;"><span style="mso-ansi-language:EN-US;"></span><font><span style="FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;">&lt;xsl:if test=&quot;position() &amp;lt;= $</span><span style="FONT-FAMILY:&#39;Courier New&#39;;"> </span><span style="FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;">ResultsPerTypeLimit &quot; &gt;</span></font></p>
<p><font><span style="FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;"></span></font><span style="mso-ansi-language:EN-US;"><font><strong>Remark:</strong> The XSL parameter values are populated in the ModifyXsltArgumentList method of the HighConfidenceWebPart web part.</font></span></font></span></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/pholpar/2007/11/13/high-confidence-results-in-moss-2007/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lesson learned (the hard way): Never use underscore in your hostname</title>
		<link>http://vspug.com/pholpar/2007/10/24/lesson-learned-the-hard-way-never-use-underscore-in-your-hostname/</link>
		<comments>http://vspug.com/pholpar/2007/10/24/lesson-learned-the-hard-way-never-use-underscore-in-your-hostname/#comments</comments>
		<pubDate>Wed, 24 Oct 2007 19:56:00 +0000</pubDate>
		<dc:creator>pholpar</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[Note &#8211; This is a repost of the original writing that was lost when the SharePointBlogs site crashed. Original article was published on 2007.05.11.
Last year, just after the release of MOSS 2007 we run into a very strange problem when we tried to configure FBA. After using this feature on B2 and B2TR more-or-less successfully [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Note &#8211; This is a repost of the original writing that was lost when the SharePointBlogs site crashed. Original article was published on 2007.05.11.</strong></p>
<p><span style="mso-ansi-language:EN-US;"><font><font>Last year, just after the release of MOSS 2007 we run into a very strange problem when we tried to configure FBA. After using this feature on B2 and B2TR more-or-less successfully on the RTM it was totally unusable. When the users entered their correct username and password the login screen appeared again without any sign of incorrect credentials or access denied message. If they provided incorrect credentials, it was handled by the system correctly (e.g. they received a warning message about the incorrect username or password).</font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"></span><span style="mso-ansi-language:EN-US;"><font><font>Using SQL Profiler we created traces that showed that using the correct credentials the FBA was successful (at least on the database level). It means that the SP responsible for FBA returned success.</font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"></span><span style="mso-ansi-language:EN-US;"><font><font>It was an interesting addition to the issue that when we checked the working with FireFox the FBA was working as it should be. Later there were issues with FireFox (it is another story) but users were able to log in at least.</font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"></span><span style="mso-ansi-language:EN-US;"><font><font>When we used the Central Admin web site there we experienced another issue that we thought may be related to the login problem: after selecting the application to manage from the HTML list on the admin pages, the selection was lost and the first item got selected, although the setting we made on the pages were applied correctly to the selected web application.</font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"></span><span style="mso-ansi-language:EN-US;"><font><font>We read all important blogs about using FBA on MOSS 2007, trying to remember what we made differently on the beta versions. We reinstalled the system several times, even the DC was reinstalled of the test domain (who knows?) without any success.</font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"></span><span style="mso-ansi-language:EN-US;"><font><font>It was interesting that there were a red ball on the right side of the status bar of the browser alerting us about the browser &quot;Could not find a privacy policy&quot; for the login page. So we played with P3P, the browser privacy settings, but FBA was still not working.</font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"></span><span style="mso-ansi-language:EN-US;"><font><font>We felt it was almost sure that the direct cause of the problem is the incorrect cookie-handling in the browser, but were not able to catch the root of the problem.</font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"></span><span style="mso-ansi-language:EN-US;"><font><font>I tried to remember what could be different between the previous beta-based and the current RTM installation. Somehow my attention was focused for a moment on the name of the MOSS server machine and I immediately knew I had found it! While we gave the name MOSS for the server previously, my colleague who made the installation started to name it MOSS_DEV recently. I did not know why, but I was sure that the underscore will be the source of our pain.</font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"></span><span style="mso-ansi-language:EN-US;"><font>After a short google I found the proof of my theory. <a title="This page" href="http://help.sap.com/saphelp_erp2005/helpdata/en/67/be9442572e1231e10000000a1550b0/content.htm">This page</a></font></span><span style="mso-ansi-language:EN-US;"><font><font> on SAP site about Fully Qualified Domain Names (FQDN) tells that &quot;The browser does not accept cookies if a host name contains the underscore character&quot;.</font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"></span><span style="mso-ansi-language:EN-US;"><font><a title="This" href="http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q275033&amp;LN=EN">This</a></font></span><span style="mso-ansi-language:EN-US;"><font><font> MS support article says that &quot;Cookies Are Not Saved If the Host Name Is Invalid&quot;.</font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"></span><span style="mso-ansi-language:EN-US;"><font>Also I found a very similar incident in IBM&#39;s knowledge base: <a title="Form login does not work when the hostname contains an underscore " href="http://publib.boulder.ibm.com/infocenter/wasinfo/v4r0/index.jsp?topic=/com.ibm.support.was40.doc/html/Security/swg21049697.html">Form login does not work when the hostname contains an underscore</a></font></span><font><font><span style="mso-ansi-language:EN-US;">. I feel this one very instructive. Unfortunately, I found it only after solving the problem myself. It could have saved a lot of time for us.</span></font></font></p>
<p><font><font><span style="mso-ansi-language:EN-US;"></span></font></font><span style="mso-ansi-language:EN-US;"><font><font>Main thing quoted, but I suggest you to read the entire article: &quot;Internet standards do specify that hostnames should not contain underscores (RFC 1123 &amp; RFC 932)&quot;.</font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"></span><span style="FONT-SIZE:12pt;mso-ansi-language:EN-US;mso-ascii-font-family:Calibri;mso-fareast-font-family:&#39;Times New Roman&#39;;mso-hansi-font-family:Calibri;mso-bidi-font-family:&#39;Times New Roman&#39;;mso-fareast-language:HU;"><font>Well, we already know it. Sad, that MS Windows Server 2003 is not aware of this when allowing users to set host name containing underscore without alerting them for the dangers. The browser made by the same company follows the RFC rules. Not very consistent.</font></span><span style="FONT-SIZE:12pt;FONT-FAMILY:&#39;Times New Roman&#39;,&#39;serif&#39;;mso-fareast-font-family:&#39;Times New Roman&#39;;mso-fareast-language:HU;"></span> </p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/pholpar/2007/10/24/lesson-learned-the-hard-way-never-use-underscore-in-your-hostname/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hunting the encoding problem in content deployment &#8211; part 3</title>
		<link>http://vspug.com/pholpar/2007/10/24/hunting-the-encoding-problem-in-content-deployment-part-3/</link>
		<comments>http://vspug.com/pholpar/2007/10/24/hunting-the-encoding-problem-in-content-deployment-part-3/#comments</comments>
		<pubDate>Wed, 24 Oct 2007 19:17:00 +0000</pubDate>
		<dc:creator>pholpar</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[In the former parts of this series I wrote about the encoding problem we encountered using the standard MOSS 2007 content deployment. In this part I will shortly describe a workaround and the final solution.
The workaround we created was a &#34;simple&#34; command line tool that iterates through the sites and pages. The special characters were [...]]]></description>
			<content:encoded><![CDATA[<p><span style="mso-ansi-language:EN-US;"><font><font>In the former parts of this series I wrote about the encoding problem we encountered using the standard MOSS 2007 content deployment. In this part I will shortly describe a workaround and the final solution.</font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"></span><span style="mso-ansi-language:EN-US;"><font><font>The workaround we created was a &quot;simple&quot; command line tool that iterates through the sites and pages. The special characters were stored as a constant string array and we computed the corresponding &#8220;encoded&#8221; characters at runtime based on the rules we descried in the previous parts. We replaced all &quot;encoded&quot; characters into the original one in all off the fields that can contain text information. This process required considerable time, especially as we had pages that contain Russian text and it is full with special characters. We had to extend the array of special characters as users add more and more content with characters we did not include originally into the array. Also, it was not easy to synchronize the correction process with the content deployment.</font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"></span><span style="mso-ansi-language:EN-US;"><font><font>We experimenting with other methods, like creating event receiver that replaces the special characters &quot;on-the-fly&quot; as content deployment pushes content to the publishing server. Unfortunately, it seems that event receivers do not fire as expected when content created through content deployment. Probably it has performance reasons.</font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"></span><span style="mso-ansi-language:EN-US;"><font><font>Other &quot;nice try&quot; was handling the problem on the database level. We created a simple tool that corrected the content directly through the content database. We even planned to create some kind of INSTEAD OF TRIGGER that inserts the corrected content instead of the &quot;encoded&quot; one by calling managed code to restore the original content.</font></font></span> </p>
<p style="MARGIN:0cm 0cm 10pt;"><span style="mso-ansi-language:EN-US;"><font><font>Fortunately we should not have to go live with this workaround as Microsoft released a hotfix for this issue and we receive that patch. After installing the hotfix we have no more problems with special characters.</font></font></span></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/pholpar/2007/10/24/hunting-the-encoding-problem-in-content-deployment-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hunting the encoding problem in content deployment &#8211; part 2</title>
		<link>http://vspug.com/pholpar/2007/10/24/hunting-the-encoding-problem-in-content-deployment-part-2/</link>
		<comments>http://vspug.com/pholpar/2007/10/24/hunting-the-encoding-problem-in-content-deployment-part-2/#comments</comments>
		<pubDate>Wed, 24 Oct 2007 19:08:00 +0000</pubDate>
		<dc:creator>pholpar</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[Note &#8211; This is a repost of the original writing that was lost when the SharePointBlogs site crashed. Original article was published on 2007.05.06.
In the previous part we saw that special characters in meta-information of publishing pages handled incorrectly by the export process (and by the content deployment that is based on the export process). [...]]]></description>
			<content:encoded><![CDATA[<p style="MARGIN:0cm 0cm 10pt;"><span style="mso-ansi-language:EN-US;"><font><font><strong>Note &#8211; This is a repost of the original writing that was lost when the SharePointBlogs site crashed. Original article was published on 2007.05.06.</strong></font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font>In the previous part we saw that special characters in meta-information of publishing pages handled incorrectly by the export process (and by the content deployment that is based on the export process). This part will show you how we used&nbsp;<a title="Lutz Roeder&#39;s .NET Reflector" href="http://www.aisto.com/roeder/dotnet/">Lutz Roeder&#39;s .NET Reflector</a> </font></span><span style="mso-ansi-language:EN-US;"><font><font>and SQL Server Profiler to check the internal working of the export process and identify the potential source of the problem.</font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"></span><span style="mso-ansi-language:EN-US;"><font><font><span style="mso-ansi-language:EN-US;">Most of the classes related to the export process are located in the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">Microsoft.SharePoint.Deployment</span><span style="mso-ansi-language:EN-US;"> namespace within the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">Microsoft.SharePoint.dll</span><span style="mso-ansi-language:EN-US;"> assembly so if not specified otherwise you should find classes I am writing about that place.</span></font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><font><span style="mso-ansi-language:EN-US;"></span></font><font><span style="mso-ansi-language:EN-US;">As we already know the export package is created by the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">Run() </span><span style="mso-ansi-language:EN-US;">method of the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">SPExport</span><span style="mso-ansi-language:EN-US;"> class. In this method the exportation (serialization) of the objects is made by the call </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">this.SerializeObjects()</span><span style="mso-ansi-language:EN-US;">. Within this method the line </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">serializer.Serialize(deployObject, writer.BaseStream)</span><span style="mso-ansi-language:EN-US;"> is responsible for serialization to the target file. The </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">serializer</span><span style="mso-ansi-language:EN-US;"> object in this case is an </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">ObjectSerializer</span><span style="mso-ansi-language:EN-US;">:</span></font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><font><span style="mso-ansi-language:EN-US;"></span></font><font><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">ObjectSerializer serializer = new ObjectSerializer(deploymentContext);</span></font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><font><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;"></span></font><font><span style="mso-ansi-language:EN-US;">In the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">ObjectSerializer(DeploymentStreamingContext deploymentContext)</span><span style="mso-ansi-language:EN-US;"> constructor you will find this line:</span></font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><font><span style="mso-ansi-language:EN-US;"></span></font><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;"><font>this.AddSerializationSurrogates(selector, this.m_context);</font></span></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;"></span><font><span style="mso-ansi-language:EN-US;">The</span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;"> AddSerializationSurrogates</span><span style="mso-ansi-language:EN-US;"> method is responsible for registering different type of serializers for the SharePoint object types that should be persisted during the export. The following line handles the serializer for the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">SPFile </span><span style="mso-ansi-language:EN-US;">object type. Since we had problems with the</span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;"> SPFile</span><span style="mso-ansi-language:EN-US;"> </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">Property</span><span style="mso-ansi-language:EN-US;"> value in the Manifest.xml, we will follow this track:</span></font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><font><span style="mso-ansi-language:EN-US;"></span></font><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;"><font>selector.AddSurrogate(typeof(SPFile), context, new FileSerializer());</font></span></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;"></span><font><span style="mso-ansi-language:EN-US;">As you see </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">SPFile</span><span style="mso-ansi-language:EN-US;"> objects are persisted using the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">FileSerializer</span><span style="mso-ansi-language:EN-US;"> object that is a derived class of </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">DeploymentSerializationSurrogate</span><span style="mso-ansi-language:EN-US;">. </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">DeploymentSerializationSurrogate</span><span style="mso-ansi-language:EN-US;"> implements the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">System.Runtime.Serialization.ISerializationSurrogate</span><span style="mso-ansi-language:EN-US;"> interface, so object data is provided to the serializer through the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">GetObjectData(object obj, SerializationInfo</span><span style="mso-ansi-language:EN-US;"> </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">info, StreamingContext context)</span><span style="mso-ansi-language:EN-US;"> method.</span></font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><font><span style="mso-ansi-language:EN-US;"></span></font><font><span style="mso-ansi-language:EN-US;">If you check the definition of this method in the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">DeploymentSerializationSurrogate</span><span style="mso-ansi-language:EN-US;"><span style="">&nbsp; </span>class, you can see that if the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">DataSet</span><span style="mso-ansi-language:EN-US;"> property of the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">obj</span><span style="mso-ansi-language:EN-US;"> object (after casting to </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">ExportObject</span><span style="mso-ansi-language:EN-US;"> <span style="">&nbsp;</span>that is a subclass of </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">DeploymentObject</span><span style="mso-ansi-language:EN-US;">) is not </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">null</span><span style="mso-ansi-language:EN-US;"> then the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">GetDataFromDataSet(object obj, SerializationInfo info, StreamingContext context)</span><span style="mso-ansi-language:EN-US;"> method is used during serialization. <span style="">&nbsp;</span>For the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">FileSerializer</span><span style="mso-ansi-language:EN-US;"> this is the case so we should check its </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">GetDataFromDataSet </span><span style="mso-ansi-language:EN-US;">method. Within this method the call </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">HandleMetaInfo(objectManager, fileMetaData.ItemArray[ 8 ], info, settings) </span><span style="mso-ansi-language:EN-US;">is responsible for persisting meta-information.</span></font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><font><span style="mso-ansi-language:EN-US;"></span></font><font><span style="mso-ansi-language:EN-US;">We investigated the SPS content database and created SQL trace during the export process and found that the file information can be read through the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">Docs </span><span style="mso-ansi-language:EN-US;">view (that is based on table </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">AllDocs</span><span style="mso-ansi-language:EN-US;">). The meta-information is stored in an image data type column called </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">MetaInfo </span><span style="mso-ansi-language:EN-US;">within the view.</span></font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><font><span style="mso-ansi-language:EN-US;"></span></font><font><span style="mso-ansi-language:EN-US;">The stored procedure </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">proc_DeplGetFileData</span><span style="mso-ansi-language:EN-US;"> is used for retrieving file information for deployment. The </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">MetaInfo</span><span style="mso-ansi-language:EN-US;"> column is the 9<sup>th</sup> field in the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">SELECT</span><span style="mso-ansi-language:EN-US;"> statement in this SP. You can see that in the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">GetDataFromDataSet </span><span style="mso-ansi-language:EN-US;">method the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">HandleMetaInfo</span><span style="mso-ansi-language:EN-US;"> method is also called using the 9<sup>th</sup> field (</span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">fileMetaData.ItemArray[ 8 ]</span><span style="mso-ansi-language:EN-US;">) of each </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">DataRow</span><span style="mso-ansi-language:EN-US;"> from the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">DataSet</span><span style="mso-ansi-language:EN-US;"> of the given</span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;"> ExportObject</span><span style="mso-ansi-language:EN-US;"> .</span></font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><font><span style="mso-ansi-language:EN-US;"></span></font><font><span style="mso-ansi-language:EN-US;">It means that within the</span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;"> HandleMetaInfo</span><span style="mso-ansi-language:EN-US;"> method the new </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">MetaInfoHandler </span><span style="mso-ansi-language:EN-US;">object instance is created using the value of the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">MetaInfo</span><span style="mso-ansi-language:EN-US;"> column.&nbsp; If you check the constructor of the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">MetaInfoHandler </span><span style="mso-ansi-language:EN-US;">you can see that the constructor parameter is casted to a byte array when calling the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">Parse(byte[] propertyBytes) </span><span style="mso-ansi-language:EN-US;">method.</span></font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><font><span style="mso-ansi-language:EN-US;"></span></font><font><span style="mso-ansi-language:EN-US;">Since the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">MetaInfo </span><span style="mso-ansi-language:EN-US;">is binary data we suspected that the following lines may cause the problem:</span></font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><font><span style="mso-ansi-language:EN-US;"></span></font><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;"><font>property.TheString = new string(chArray, startIndex, (num2 &#8211; startIndex) + 1);</font></span></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;"></span><span style="mso-ansi-language:EN-US;"><font>And later:</font></span></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><span style="mso-ansi-language:EN-US;"></span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;"><font>property.Value = new string(chArray, num3, index &#8211; num3);</font></span></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;"></span><font><span style="mso-ansi-language:EN-US;">These lines handle parts of </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">MetaInfo</span><span style="mso-ansi-language:EN-US;"> as simple ASCII text converting each byte to a single character. This is incorrect in the case of special characters since these characters may consist of two (or more) bytes.</span></font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><font><span style="mso-ansi-language:EN-US;"></span></font><span style="mso-ansi-language:EN-US;"><font>Instead of these, one should use the following lines:</font></span></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><span style="mso-ansi-language:EN-US;"></span><font><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">UTF8Encoding utfEncoding = new UTF8Encoding();</span></font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><font><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;"></span></font><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;"><font>property.TheString = utfEncoding.GetString(propertyBytes, startIndex, (num2 &#8211; startIndex) + 1);</font></span></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;"></span><span style="mso-ansi-language:EN-US;"><font>And similarly:</font></span></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><span style="mso-ansi-language:EN-US;"></span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;"><font>UTF8Encoding utfEncoding = new UTF8Encoding();</font></span></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;"></span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;"><font>property.Value = utfEncoding.GetString(propertyBytes, num3, index &#8211; num3);</font></span></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;"></span><span style="mso-ansi-language:EN-US;"><font>We should note that the following line may also cause problem:</font></span></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><span style="mso-ansi-language:EN-US;"></span><font><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">property.Name = new string(chArray, num3, index &#8211; num3);</span></font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><font><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;"></span></font><span style="mso-ansi-language:EN-US;"><font>Probably we had no issue with that because we don&#39;t use special characters in property names. In Hungary we learned the hard way in previous SharePoint versions that it&#39;s best to avoid accentuated letters in field, list, view, etc. names.</font></span></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><span style="mso-ansi-language:EN-US;"></span><font><span style="mso-ansi-language:EN-US;">We tried to prove our theory using a single console application. For this application we copied the source of the entire </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">MetaInfoHandler</span><span style="mso-ansi-language:EN-US;">, </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">MetaInfoProperty</span><span style="mso-ansi-language:EN-US;"> and </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">SerializationInfoHelper</span><span style="mso-ansi-language:EN-US;"> classes from .NET Reflector into our project (since all of these classes are declared as </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">internal</span><span style="mso-ansi-language:EN-US;"> we could not use them directly). Then we made a </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">MetaInfoHandlerEx</span><span style="mso-ansi-language:EN-US;"> class that is equivalent with the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">MetaInfoHandler</span><span style="mso-ansi-language:EN-US;"> except the above mentioned code modifications.</span></font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><font><span style="mso-ansi-language:EN-US;"></span></font><font><span style="mso-ansi-language:EN-US;">In the main program we connected directly to the SPS content database and selected the </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">MetaInfo</span><span style="mso-ansi-language:EN-US;"> for a given publishing page that contains special characters in its page content. We tried to use both </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">MetaInfoHandler</span><span style="mso-ansi-language:EN-US;"> and </span><span style="COLOR:#1f497d;FONT-FAMILY:&#39;Courier New&#39;;mso-ansi-language:EN-US;mso-themecolor:text2;">MetaInfoHandlerEx </span><span style="mso-ansi-language:EN-US;">classes to get the value of the property.</span></font></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><font><span style="mso-ansi-language:EN-US;"></span></font><span style="mso-ansi-language:EN-US;"><font>Our results show that the original version returns the incorrect value but our version handles the special characters correctly.</font></span></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><span style="mso-ansi-language:EN-US;"></span><span style="mso-ansi-language:EN-US;"><font>The code of this application is attached to this post. Don&#39;t forget to adjust the constant values (SQL server name, content database name, publishing page name whose content contains the special characters) in the code to match with your environment before making the test.</font></span></font></span></p>
<p><span style="mso-ansi-language:EN-US;"><font><span style="mso-ansi-language:EN-US;"></span><font><span style="mso-ansi-language:EN-US;">PS: We shared our founding more than a month ago with a local MS consultant we worked together on a project and whose responsibility was to help us to solve this kind of issues on the project. Unfortunately he told us that he can do nothing with this information.</span></font></font></span></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/pholpar/2007/10/24/hunting-the-encoding-problem-in-content-deployment-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
