<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Cliff Green's Blog</title><link>http://blogs.msdn.com/cliffgreen/default.aspx</link><description /><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>SharePoint Console Application Permissions for Read Only Access</title><link>http://blogs.msdn.com/cliffgreen/archive/2009/08/22/sharepoint-console-application-permissions-for-read-only-access.aspx</link><pubDate>Sat, 22 Aug 2009 15:22:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9880405</guid><dc:creator>green.cliff</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/cliffgreen/comments/9880405.aspx</comments><wfw:commentRss>http://blogs.msdn.com/cliffgreen/commentrss.aspx?PostID=9880405</wfw:commentRss><description>&lt;p&gt;I was recently challenged with trying to come up with a least privilege scenario for running a console application or windows service against a SharePoint Farm to perform read-only type operations.&amp;nbsp; Without the correct permissions there are several exceptions you will run into, including File IO, UnauthorizedAccess, SPException, etc.&amp;nbsp; A joy to wade through.&amp;nbsp; :-)&amp;nbsp; &lt;/p&gt; &lt;p&gt;I used this &lt;a href="http://support.microsoft.com/kb/935751"&gt;KB article&lt;/a&gt; as a starting point for what we knew would work.&amp;nbsp; It states that the identity used to run the console application should be the following:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Farm Administrator&lt;/li&gt; &lt;li&gt;Read/Write database permissions on the configuration and content databases.&lt;/li&gt; &lt;li&gt;Site collection administrator&lt;/li&gt; &lt;li&gt;Permissions to each site in the site collection&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;I started my quest with no permissions granted on the farm and slowly elevated them until I was able to successfully iterate the object model.&amp;nbsp; I ended up with close to what is published above but I was showing DBO permissions were required for the database.&amp;nbsp; After consulting with some people internally I was able to use the SQL Role WSS_Content_Application_Pools for the configuration database, but was still requiring DBO for the content databases.&amp;nbsp; Again, some help internally brought to my attention that a stored procedure was required to enumerate the sites that exist in the site collection.&amp;nbsp; I was able to grant execute permissions for the user on the content databases using the following command:&lt;/p&gt; &lt;div id="codeSnippetWrapper"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;GRANT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;EXECUTE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;TO&lt;/span&gt; [&lt;span style="color: #0000ff"&gt;DOMAIN&lt;/span&gt;\username]&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;
&lt;p&gt;I also changed the permissions for the user on the content database to db_datareader.&amp;nbsp; After the changes were made the console application was able to successfully iterate the content in the site collection in a read-only fashion.&amp;nbsp; The final permissions were as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Farm Administrator&lt;/li&gt;
&lt;li&gt;db_datareader permissions on the content databases&lt;/li&gt;
&lt;li&gt;WSS_Content_Application_Pools permissions on the SharePoint_Config (default name) database&lt;/li&gt;
&lt;li&gt;GRANT EXECUTE permission on the stored procs in the content database&lt;/li&gt;
&lt;li&gt;Site collection administrator&lt;/li&gt;
&lt;li&gt;Permissions to each site in the site collection&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;This could be further reduced to the exact stored procs required in the content databases, but I’ll leave that for another day.&amp;nbsp; Write permissions don’t seem to be required on the content database as indicated in the KB and we can leverage the SharePoint specific SQL role for the configuration database.&amp;nbsp; The fact that we can reduce this to db_datareader instead of read / write on the content databases should make some of the DBAs of the world a little happier.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9880405" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/SharePoint/default.aspx">SharePoint</category></item><item><title>Reporting Services: Value Either too Large or too Small for a Decimal</title><link>http://blogs.msdn.com/cliffgreen/archive/2009/04/23/reporting-services-value-either-too-large-or-too-small-for-a-decimal.aspx</link><pubDate>Thu, 23 Apr 2009 20:09:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9565093</guid><dc:creator>green.cliff</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/cliffgreen/comments/9565093.aspx</comments><wfw:commentRss>http://blogs.msdn.com/cliffgreen/commentrss.aspx?PostID=9565093</wfw:commentRss><description>&lt;p&gt;I have seen a few reports recently that have been upgraded from SSRS 2005 to SSRS 2008 where a ‘Value either too Large or too small for a decimal’ appears in the chart under certain circumstances.&amp;nbsp; This typically manifest itself when an expression in the data series for the chart looks something like that below:&lt;/p&gt; &lt;div&gt; &lt;div&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;=IIf(Fields!ISMONEYAMOUNTSW.Value = 0 &lt;span style="color: #0000ff"&gt;and&lt;/span&gt; Fields!TIMEINSECONDS.Value &amp;gt; 0 , 
    Sum(Fields!TIMEINSECONDS.Value), 
    Iif(Fields!ISMONEYAMOUNTSW.Value = 1 &lt;span style="color: #0000ff"&gt;and&lt;/span&gt; Fields!TOTALAMOUNT.Value &amp;gt; 0,
        SUM(Fields!TOTALAMOUNT.Value),&lt;span style="color: #006080"&gt;""&lt;/span&gt;))&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Notice the empty string in the last expression as part of the FalsePart of the IIf expression.&amp;nbsp; This also happens if ‘Nothing’ is used.&amp;nbsp; These values, “” or ‘Nothing’, don’t evaluate to decimals in this case and the rendering engine has trouble converting them.&amp;nbsp; In the previous version I imagine this was ignored.&amp;nbsp; In SQL Reporting Services 2008 the value attempts to convert to the decimal type unsuccessfully.&amp;nbsp; The fix is simply to change the expression to a ‘0’ so that it is evaluated properly as shown below.&lt;/p&gt;
&lt;div&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;=Iif(Fields!ISMONEYAMOUNTSW.Value = 0 &lt;span style="color: #0000ff"&gt;And&lt;/span&gt; Fields!TIMEINSECONDS.Value &amp;gt; 0 , 
    Sum(Fields!TIMEINSECONDS.Value), 
    Iif(Fields!ISMONEYAMOUNTSW.Value = 1 &lt;span style="color: #0000ff"&gt;And&lt;/span&gt; Fields!TOTALAMOUNT.Value &amp;gt; 0,
        SUM(Fields!TOTALAMOUNT.Value),0))&lt;/pre&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9565093" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/Reporting+Services/default.aspx">Reporting Services</category></item><item><title>SharePoint CopyIntoItems and Setting a Document Content Type</title><link>http://blogs.msdn.com/cliffgreen/archive/2009/04/21/sharepoint-copyintoitems-and-setting-a-document-content-type.aspx</link><pubDate>Tue, 21 Apr 2009 21:51:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9560014</guid><dc:creator>green.cliff</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/cliffgreen/comments/9560014.aspx</comments><wfw:commentRss>http://blogs.msdn.com/cliffgreen/commentrss.aspx?PostID=9560014</wfw:commentRss><description>&lt;p&gt;I can’t take credit or this one, but a colleague I have been working with was able to figure this out.&amp;nbsp; He doesn’t blog, so I am sharing it with the greater community.&amp;nbsp; Our quest was to upload a document into a document library using the Copy.asmx web service and set the content type on the document as well as other field information as part of the upload.&amp;nbsp; The method takes a FieldInformation array, so at first glance this seemed like it was going to be pretty easy.&amp;nbsp; We all know what happens next.&lt;/p&gt; &lt;p&gt;Initial attempts were successful at uploading, but not setting the content type.&amp;nbsp; The content type would always end up as Document, the default.&amp;nbsp; We tried several different variations, but nothing worked.&amp;nbsp; There are also &lt;a href="http://oricode.wordpress.com/2008/07/03/upload-a-file-to-sharepoint-2007-using-webservices-with-a-specific-content-type/" target="_blank"&gt;others&lt;/a&gt; that seem to have had the same fate and come up with other workarounds.&lt;/p&gt; &lt;p&gt;My colleague had the idea to call the GetItem() method for an item that had the content type already set, and there was the answer.&amp;nbsp; The type of field for a content type is FieldType.Choice, not FieldType.Text, which was the assumption all along.&amp;nbsp; Calling GetItem() returned the following:&lt;/p&gt; &lt;div&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;FieldInformation&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Type&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Choice"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;DisplayName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Content Type"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;InternalName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="ContentType"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="***"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;From there it was straightforward.&amp;nbsp; Uploading and setting the content type in one simple method call.&amp;nbsp; He asked that I give his company a plug, so … those people at &lt;a href="http://www.sas.com/" target="_blank"&gt;SAS&lt;/a&gt; are pretty smart aren’t they. :-)&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9560014" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/Web+Services/default.aspx">Web Services</category></item><item><title>Reporting Services Migration Error: Object reference not set to an instance of an object.</title><link>http://blogs.msdn.com/cliffgreen/archive/2009/03/27/reporting-services-migration-error-object-reference-not-set-to-an-instance-of-an-object.aspx</link><pubDate>Fri, 27 Mar 2009 15:04:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9513914</guid><dc:creator>green.cliff</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/cliffgreen/comments/9513914.aspx</comments><wfw:commentRss>http://blogs.msdn.com/cliffgreen/commentrss.aspx?PostID=9513914</wfw:commentRss><description>&lt;p&gt;In working with a customer doing a migration from Reporting Services 2005 to 2008 an error appeared when in preview mode that didn’t appear in the previous version.&amp;nbsp; The error was simply #Error in the report and the Error pane in Visual Studio showed The Value expression for the field ‘&amp;lt;my field name&amp;gt;’ contains an error: Object reference not set to an instance of an object.&amp;nbsp; We have all seen the ‘object reference not set’ at one point in our lives.&amp;nbsp; After doing some trouble shooting it turns out that the report was calling out to an external assembly to do some work building a data table and then getting the summary values for the data table in another call.&amp;nbsp; The data table was originally built using a hidden table in the report and the values were accessed in a field in another report table.&amp;nbsp; Because of the positioning of the tables the hidden table would execute first, therefore creating the data table in code, and the expression to get the values would execute afterwards.&lt;/p&gt; &lt;p&gt;This reliance of execution order was the root cause of the problem.&amp;nbsp; In SSRS 2008 the execution order has changed.&amp;nbsp; Refer to &lt;a href="http://blogs.msdn.com/robertbruckner/archive/2008/08/11/on-demand-report-processing-in-rs-2008.aspx" target="_blank"&gt;Robert Bruckner’s blog&lt;/a&gt; for more information.&amp;nbsp; For this particular report the data table was not created first which caused the row collecting summary data from the expected table to be null.&amp;nbsp; This in turn caused the value being retrieved to be null.&amp;nbsp; Although the code checked for (x == DbNull.Value) it didn’t explicitly check for (x == null), so a cast later on in the code block created the ‘object reference not set to an instance of an object’ error.&lt;/p&gt; &lt;p&gt;What can cause confusion is the error itself, which says that Value expression for the field &amp;lt;y&amp;gt; contains an error.&amp;nbsp; I racked my brain trying to figure out why that particular field was causing the error.&amp;nbsp; It wasn’t.&amp;nbsp; The logic, to my best guess, just parses the last parameter calling out to the external assembly that is a field in the report.&amp;nbsp; I took my field that was stated to be the issue and changed it to an empty string.&amp;nbsp; The next run of the report showed that the next parameter was the issue, and the next and the next until I had eliminated all of them.&lt;/p&gt; &lt;p&gt;The important thing to remember here is that relying on execution order in a report may cause issues when migrating to SSRS 2008.&amp;nbsp; Try to avoid it if at all possible.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9513914" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/Reporting+Services/default.aspx">Reporting Services</category></item><item><title>SharePoint Tools Released</title><link>http://blogs.msdn.com/cliffgreen/archive/2009/02/09/sharepoint-tools-released.aspx</link><pubDate>Mon, 09 Feb 2009 17:26:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9408719</guid><dc:creator>green.cliff</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/cliffgreen/comments/9408719.aspx</comments><wfw:commentRss>http://blogs.msdn.com/cliffgreen/commentrss.aspx?PostID=9408719</wfw:commentRss><description>&lt;p&gt;I work in the ISV Practice here at Microsoft.&amp;nbsp; There are two tools recently released to the SharePoint community that should have ISVs and Enterprise customers excited.&amp;nbsp; &lt;/p&gt; &lt;p&gt;&lt;a href="http://code.msdn.microsoft.com/SPDisposeCheck" target="_blank"&gt;SPDisposeCheck&lt;/a&gt; provides a static source code analysis tool to check for leaks that may be caused by not disposing of SPSite and SPWeb objects properly.&amp;nbsp; While most people that have worked with SharePoint know of these perils, this tool can provide a second set of eyes on your code.&amp;nbsp; For those new to the product, SPDisposeCheck will allow you to uncover those instances where improperly disposed objects would result in leaked memory.&amp;nbsp; Instances where this occurs isn’t always obvious, so the tool can help reduce leaks that make it to production.&lt;/p&gt; &lt;p&gt;Another exciting tool is the &lt;a href="http://blogs.msdn.com/sharepoint/archive/2009/02/05/sharepoint-diagnostics-spdiag-tool-v1-0-for-sharepoint-products-and-technologies.aspx" target="_blank"&gt;SPDiag&lt;/a&gt; tool.&amp;nbsp; This tool greatly simplifies gathering data required for troubleshooting issues in a SharePoint environment.&amp;nbsp; When working on issues or performance problems getting a good snapshot if the farm environment can help uncover the root cause of the issues quickly and get customers back to work.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9408719" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/SharePoint/default.aspx">SharePoint</category></item><item><title>Discover SharePoint Context within an Integrated SSRS report</title><link>http://blogs.msdn.com/cliffgreen/archive/2008/12/12/discover-sharepoint-context-within-an-integrated-ssrs-report.aspx</link><pubDate>Fri, 12 Dec 2008 20:09:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9202784</guid><dc:creator>green.cliff</dc:creator><slash:comments>14</slash:comments><comments>http://blogs.msdn.com/cliffgreen/comments/9202784.aspx</comments><wfw:commentRss>http://blogs.msdn.com/cliffgreen/commentrss.aspx?PostID=9202784</wfw:commentRss><description>&lt;p&gt;With SQL Reporting Services integration with SharePoint there may be a need to be contextually aware of the site or list where your report resides.&amp;nbsp; With the ability to add code or reference custom assemblies in our report we have a starting point to gather this information and leverage information that may be available to us in a site.&amp;nbsp; The first thing I thought of when thinking through this issue was that I could leverage the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spcontext.aspx" target="_blank"&gt;SPContext&lt;/a&gt; object.&amp;nbsp; This would provide the ability to get the current site Url and reference information that way.&amp;nbsp; Unfortunately, the reference to SPContext within the report is null because it is being rendered in an IFRAME.&amp;nbsp; So we can't use that mechanism to do that.&amp;nbsp; So the next idea was to get a reference to HttpContext and leverage that in order to find out where we are in SharePoint.&amp;nbsp; When a report runs from a SharePoint document library it runs within the RSViewerPage.aspx page.&amp;nbsp; The actual Url request in my environment is, &lt;a title="http://cliffgre-mossvm/SiteDirectory/reports/_layouts/ReportServer/RSViewerPage.aspx?RelativeReportUrl=/SiteDirectory/reports/RDL/TestReport.rdl&amp;amp;Source=http%3A%2F%2Fcliffgre%2Dmossvm%2FSiteDirectory%2Freports%2FRDL%2FForms%2FAllItems%2Easpx&amp;amp;DefaultItemOpen=0" href="http://cliffgre-mossvm/SiteDirectory/reports/_layouts/ReportServer/RSViewerPage.aspx?RelativeReportUrl=/SiteDirectory/reports/RDL/TestReport.rdl&amp;amp;Source=http%3A%2F%2Fcliffgre%2Dmossvm%2FSiteDirectory%2Freports%2FRDL%2FForms%2FAllItems%2Easpx&amp;amp;DefaultItemOpen=0"&gt;http://cliffgre-mossvm/SiteDirectory/reports/_layouts/ReportServer/RSViewerPage.aspx?RelativeReportUrl=/SiteDirectory/reports/RDL/TestReport.rdl&amp;amp;Source=http%3A%2F%2Fcliffgre%2Dmossvm%2FSiteDirectory%2Freports%2FRDL%2FForms%2FAllItems%2Easpx&amp;amp;DefaultItemOpen=0&lt;/a&gt;.&amp;nbsp; The report, however, is run using a pointer to the Report Server.&amp;nbsp; In my environment the Web Application lives in &lt;a href="http://cliffgre-mossvm"&gt;http://cliffgre-mossvm&lt;/a&gt;.&amp;nbsp; When I request a report it runs in a reference to &lt;a href="http://cliffgre-mossvm:8000/ReportServer"&gt;&lt;font color="#000000"&gt;http://cliffgre-mossvm:8000/ReportServer&lt;/font&gt;&lt;/a&gt;, so it runs completely out of the SharePoint environment.&amp;nbsp; The Url request in the report looks something like this:&lt;/p&gt; &lt;div&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;http:&lt;span style="color: #008000"&gt;//cliffgre-mossvm:8000/ReportServer/Reserved.ReportServer?http://cliffgre-mossvm/SiteDirectory/reports/RDL/TestReport.rdl&lt;/span&gt;
&amp;amp;rs:SessionID=l1ahe1yas2icsrjuiar0na55&amp;amp;rs:command=Render&amp;amp;rs:Format=HTML4.0&amp;amp;rc:HTMLFragment=&lt;span style="color: #0000ff"&gt;true&lt;/span&gt;&amp;amp;rc:Section=1
&amp;amp;rc:StreamRoot=/SiteDirectory/reports/Reserved.ReportViewerWebPart.axd?ReportSession=l1ahe1yas2icsrjuiar0na55&amp;amp;
ControlID=05e0aa50c74646f3858bf6847b08f5f2&amp;amp;Culture=1033&amp;amp;UICulture=1033&amp;amp;ReportStack=1&amp;amp;OpType=ReportImage&amp;amp;StreamID=
&amp;amp;rc:ResourceStreamRoot=/SiteDirectory/reports/Reserved.ReportViewerWebPart.axd?ReportSession=l1ahe1yas2icsrjuiar0na55
&amp;amp;ControlID=05e0aa50c74646f3858bf6847b08f5f2&amp;amp;Culture=1033&amp;amp;UICulture=1033&amp;amp;ReportStack=1&amp;amp;OpType=ReportImage&amp;amp;ResourceStreamID=
&amp;amp;rc:ActionScript=ClientReport05e0aa50c74646f3858bf6847b08f5f2.ActionHandler&amp;amp;rc:StyleStream=&lt;span style="color: #0000ff"&gt;true&lt;/span&gt;&amp;amp;rc:LinkTarget=_top
&amp;amp;rc:UserAgent=Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.2;+.NET+CLR+1.1.4322;+.NET+CLR+2.0.50727;+.NET+CLR+3.0.04506.30;+InfoPath.2;+.NET+CLR+3.0.04506.648;+.NET+CLR+3.5.21022)
&amp;amp;rc:Toolbar=&lt;span style="color: #0000ff"&gt;false&lt;/span&gt;&amp;amp;rs:ErrorResponseAsXml=&lt;span style="color: #0000ff"&gt;true&lt;/span&gt;&amp;amp;rs:AllowNewSessions=false&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;One of the things that gets passed as part of the query string is the path to the report.&amp;nbsp; Notice the first line above after the question mark (?).&amp;nbsp; We can leverage that information and parse the Url in order to find out the site and list where the report lives.&amp;nbsp; So now we have the Url to the report and we can leverage the SharePoint object model to get a reference to SPSite, SPWeb and down to SPList.&amp;nbsp; Because we are running a custom assembly in reporting services it will have to be marked to AllowPartiallyTrustedCallers using the [assembly: AllowPartiallyTrustedCallers] attribute.&lt;/p&gt;
&lt;p&gt;If only things were that simple.&amp;nbsp; Once we add the code to our custom assembly and install it in the GAC we will get the error message below.&lt;/p&gt;
&lt;div&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;SecurityException: Request &lt;span style="color: #0000ff"&gt;for&lt;/span&gt; the permission of type 
&lt;span style="color: #006080"&gt;'Microsoft.SharePoint.Security.SharePointPermission, 
Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, 
PublicKeyToken=71e9bce111e9429c'&lt;/span&gt; failed.
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In order to get around this problem we have to assert the required SharePoint permissions in order to have access to the SharePoint object model.&amp;nbsp; By surrounding our code with an Assert() for SharePointPermission our code will run and allow us to navigate the SharePoint object model as we see fit.&amp;nbsp; The full coding example is shown below.&amp;nbsp; Although it only simply returns the .PortalName and .Url properties, it can be extended to meet your needs.&lt;/p&gt;
&lt;div&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; GetInfo() {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; siteInfo = &lt;span style="color: #006080"&gt;""&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;try&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; siteCollectionUrl = &lt;span style="color: #006080"&gt;""&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; queryString = HttpContext.Current.Request.Url.ToString();&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; indexStart = (queryString.IndexOf(&lt;span style="color: #006080"&gt;"?"&lt;/span&gt;)+1);&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; indexEnd = queryString.IndexOf( &lt;span style="color: #006080"&gt;"&amp;amp;"&lt;/span&gt; );&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; reportUrl = queryString.Substring( indexStart, (indexEnd-indexStart) );&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt;         siteCollectionUrl = reportUrl.Substring( 0, reportUrl.LastIndexOf(&lt;span style="color: #006080"&gt;"/"&lt;/span&gt;) );&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt;         SharePointPermission sharepointPerm = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SharePointPermission( PermissionState.Unrestricted );&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  13:&lt;/span&gt;         sharepointPerm.Assert();&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  14:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  15:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;using&lt;/span&gt;( SPSite siteCollection = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SPSite( siteCollectionUrl ) ) {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  16:&lt;/span&gt;             siteInfo = siteCollection.PortalName + &lt;span style="color: #006080"&gt;": "&lt;/span&gt;+ siteCollection.Url;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  17:&lt;/span&gt;         }&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  18:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  19:&lt;/span&gt;         sharepointPerm.Deny();&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  20:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  21:&lt;/span&gt;     } &lt;span style="color: #0000ff"&gt;catch&lt;/span&gt;( Exception ex ) {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  22:&lt;/span&gt;         siteInfo = ex.Message + ex.StackTrace;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  23:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  24:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; siteInfo;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  25:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Now that we have done this we have a report that can leverage the SharePoint object model as needed.&amp;nbsp; Of course this won't work within Visual Studio so the report has to be deployed to SharePoint in order for the code to run properly.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9202784" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/Reporting+Services/default.aspx">Reporting Services</category><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/SSRS+Code+Examples/default.aspx">SSRS Code Examples</category><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/CAS/default.aspx">CAS</category></item><item><title>Controlling Page Size in a Reporting Services Report</title><link>http://blogs.msdn.com/cliffgreen/archive/2008/11/12/controlling-page-size-in-a-reporting-services-report.aspx</link><pubDate>Wed, 12 Nov 2008 23:29:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9064227</guid><dc:creator>green.cliff</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/cliffgreen/comments/9064227.aspx</comments><wfw:commentRss>http://blogs.msdn.com/cliffgreen/commentrss.aspx?PostID=9064227</wfw:commentRss><description>&lt;p&gt;The default page size in the US is Letter, 8.5in x 11in.&amp;nbsp; In other parts of the world A4 (8.3in x 11.7in) is the standard.&amp;nbsp; Reports in Reporting Services are hard coded as part of the design process.&amp;nbsp; In order to control the page size in the rendering process we need to pass the proper &lt;a href="http://msdn.microsoft.com/en-us/library/aa179622(SQL.80).aspx" target="_blank"&gt;Device Information Settings&lt;/a&gt; to the report at run time.&amp;nbsp; This will work for physical page oriented renders like PDF, Image, etc.&amp;nbsp; This is a simple Xml string that can be passed as a parameter to the report in order to control these settings.&amp;nbsp; Each export type has a different set of properties that can be overridden and controlled in this way.&amp;nbsp; The Device Info Settings for a PDF document can be found &lt;a href="http://msdn.microsoft.com/en-us/library/aa179643(SQL.80).aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;If we are using the Report Viewer control to display the reports we will need to disable the ability to print a report and potentially disable exporting the report, depending on the use cases we want to support.&amp;nbsp; To still provide this capability to our users we can expose the print and export properties using a link button or other postback capable control.&amp;nbsp; We can also expose the available print and export formats using a drop down or other mechanism.&amp;nbsp; Now when the user chooses to print or export the report we can override the process by passing the device info settings for the page height and width when the report is rendered.&amp;nbsp; In the example below we are exporting to PDF and passing the page height and width to match an A4 paper size as the targeted device (line 66).&lt;/p&gt; &lt;div&gt; &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; RenderReportToClient()&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     &lt;span style="color: #008000"&gt;//set credentials&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     RSExecuteProxy.ReportExecutionService rs = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; RSExecuteProxy.ReportExecutionService();&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;     rs.Credentials = System.Net.CredentialCache.DefaultCredentials;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;     RSProxy.ReportingService2005 rsInfo = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; RSProxy.ReportingService2005();&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;     rsInfo.Credentials = System.Net.CredentialCache.DefaultCredentials;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt;     &lt;span style="color: #008000"&gt;// init render args&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;[] result = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; reportPath = rptViewer.ServerReport.ReportPath;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  13:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; format = &lt;span style="color: #006080"&gt;"PDF"&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  14:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; historyId = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  15:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  16:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; encoding;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  17:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; mimeType;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  18:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; extension;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  19:&lt;/span&gt;     RSExecuteProxy.Warning[] warnings = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  20:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;[] streamIDs = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  21:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  22:&lt;/span&gt;     &lt;span style="color: #008000"&gt;//init exec info&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  23:&lt;/span&gt;     RSExecuteProxy.ExecutionInfo execInfo = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; RSExecuteProxy.ExecutionInfo();&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  24:&lt;/span&gt;     RSExecuteProxy.ExecutionHeader execHeader = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; RSExecuteProxy.ExecutionHeader();&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  25:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  26:&lt;/span&gt;     rs.ExecutionHeaderValue = execHeader;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  27:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  28:&lt;/span&gt;     &lt;span style="color: #008000"&gt;//get report&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  29:&lt;/span&gt;     execInfo = rs.LoadReport(reportPath, historyId);&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  30:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  31:&lt;/span&gt;     String SessionId = rs.ExecutionHeaderValue.ExecutionID;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  32:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  33:&lt;/span&gt;     &lt;span style="color: #008000"&gt;//get parameter info&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  34:&lt;/span&gt;     ReportParameterInfoCollection parameters = rptViewer.ServerReport.GetParameters();&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  35:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  36:&lt;/span&gt;     &lt;span style="color: #008000"&gt;//figure out how many parameters we will have &lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  37:&lt;/span&gt;     &lt;span style="color: #008000"&gt;//those with multi-value will need there own ParameterValue in the array&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  38:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; paramCount = 0;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  39:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  40:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (ReportParameterInfo pramInfo &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; parameters)&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  41:&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  42:&lt;/span&gt;         paramCount += pramInfo.Values.Count;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  43:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  44:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  45:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  46:&lt;/span&gt;     RSExecuteProxy.ParameterValue[] prams = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SSRSWeb.RSExecuteProxy.ParameterValue[paramCount];&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  47:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  48:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; currentPramPosition = 0;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  49:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  50:&lt;/span&gt;     &lt;span style="color: #008000"&gt;//set pram values&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  51:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (ReportParameterInfo pramInfo &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; parameters)&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  52:&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  53:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; pramValue &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; pramInfo.Values)&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  54:&lt;/span&gt;         {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  55:&lt;/span&gt;             prams[currentPramPosition] = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SSRSWeb.RSExecuteProxy.ParameterValue();&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  56:&lt;/span&gt;             prams[currentPramPosition].Label = pramInfo.Name;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  57:&lt;/span&gt;             prams[currentPramPosition].Name = pramInfo.Name;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  58:&lt;/span&gt;             prams[currentPramPosition].Value = pramValue;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  59:&lt;/span&gt;             currentPramPosition++;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  60:&lt;/span&gt;         }&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  61:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  62:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  63:&lt;/span&gt;     rs.SetExecutionParameters(prams, &lt;span style="color: #006080"&gt;"en-US"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  64:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  65:&lt;/span&gt;     &lt;span style="color: #008000"&gt;//build the device settings  (A4 8.3 × 11.7)&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  66:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; deviceInfo = &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;.Format(&lt;span style="color: #006080"&gt;"&amp;lt;DeviceInfo&amp;gt;&amp;lt;PageHeight&amp;gt;{0}&amp;lt;/PageHeight&amp;gt;&amp;lt;PageWidth&amp;gt;{1}&amp;lt;/PageWidth&amp;gt;&amp;lt;/DeviceInfo&amp;gt;"&lt;/span&gt;, &lt;span style="color: #006080"&gt;"11.7in"&lt;/span&gt;, &lt;span style="color: #006080"&gt;"8.3in"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  67:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  68:&lt;/span&gt;     &lt;span style="color: #008000"&gt;//get report bytes&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  69:&lt;/span&gt;     result = rs.Render(format, deviceInfo, &lt;span style="color: #0000ff"&gt;out&lt;/span&gt; extension, &lt;span style="color: #0000ff"&gt;out&lt;/span&gt; encoding, &lt;span style="color: #0000ff"&gt;out&lt;/span&gt; mimeType, &lt;span style="color: #0000ff"&gt;out&lt;/span&gt; warnings, &lt;span style="color: #0000ff"&gt;out&lt;/span&gt; streamIDs);&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  70:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  71:&lt;/span&gt;     Response.ClearContent();&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  72:&lt;/span&gt;     Response.AppendHeader(&lt;span style="color: #006080"&gt;"Content-Disposition"&lt;/span&gt;, &lt;span style="color: #006080"&gt;"inline;filename=report.pdf"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  73:&lt;/span&gt;     Response.AppendHeader(&lt;span style="color: #006080"&gt;"content-length"&lt;/span&gt;, result.Length.ToString());&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  74:&lt;/span&gt;     Response.ContentType = &lt;span style="color: #006080"&gt;"application/pdf"&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  75:&lt;/span&gt;     Response.BinaryWrite(result);&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  76:&lt;/span&gt;     Response.Flush();&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  77:&lt;/span&gt;     Response.Close();&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  78:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;When the report is saved you can view the PDF and examine the properties and notice that the page height and width is 8.3in x 11.7in as specified.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9064227" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/Reporting+Services/default.aspx">Reporting Services</category><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/SSRS+Code+Examples/default.aspx">SSRS Code Examples</category></item><item><title>SharePoint Web Part Embedded Resource Permissions</title><link>http://blogs.msdn.com/cliffgreen/archive/2008/10/27/sharepoint-web-part-embedded-resource-permissions.aspx</link><pubDate>Mon, 27 Oct 2008 17:45:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9018314</guid><dc:creator>green.cliff</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/cliffgreen/comments/9018314.aspx</comments><wfw:commentRss>http://blogs.msdn.com/cliffgreen/commentrss.aspx?PostID=9018314</wfw:commentRss><description>&lt;p&gt;It is a normal expectation for companies to embed resources like javascript, CSS and other resources in an assembly.&amp;nbsp; Web Parts are no exceptions.&amp;nbsp; For those of you that deploy everything to the GAC, you can disregard the remainder of this post.&amp;nbsp; The rest of you, bear with me.&amp;nbsp; If we are not deploying to the GAC we are typically deploying to the bin.&amp;nbsp; The bin directory in SharePoint has the following permissions by default; full control for SYSTEM, Administrators and WSS_ADMIN_WPG groups, and read-only access for WSS_WPG group.&amp;nbsp; This is not sufficient for embedded resources to be loaded by accounts that don't exists in one of these groups.&amp;nbsp; If you run an assembly with embedded resources with anything other than an account that is in one of these groups you will get the following error:&lt;/p&gt; &lt;div&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;Exception raised when trying to access embedded resources:
System.UnauthorizedAccessException: Access to the path &lt;span style="color: #006080"&gt;'C:\inetpub\wwwroot\wss\VirtualDirectories\80\bin\SampleWP.DLL'&lt;/span&gt; &lt;span style="color: #0000ff"&gt;is&lt;/span&gt; denied. 
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
at System.IO.File.GetLastWriteTimeUtc(String path) at System.IO.File.GetLastWriteTime(String path) 
at System.Web.Handlers.AssemblyResourceLoader.GetAssemblyInfoWithAssertInternal(Assembly assembly) 
at System.Web.Handlers.AssemblyResourceLoader.GetAssemblyInfo(Assembly assembly) 
at System.Web.Handlers.AssemblyResourceLoader.GetWebResourceUrlInternal(Assembly assembly, String resourceName, Boolean htmlEncoded) 
at System.Web.Handlers.AssemblyResourceLoader.GetWebResourceUrl(Type type, String resourceName, Boolean htmlEncoded) 
at System.Web.UI.ClientScriptManager.GetWebResourceUrl(Page owner, Type type, String resourceName, Boolean htmlEncoded) 
at System.Web.UI.ClientScriptManager.RegisterClientScriptResource(Type type, String resourceName) 
at TestWebPart.ResourcePermissionTest.OnPreRender(EventArgs e)
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The assembly doesn't have permission to access the bin directory.&amp;nbsp; If you don't get this error do an IIS reset and then access the web part as a user that isn't in one of these groups.&amp;nbsp; The difficult part of figuring this out was that if a user with permissions to write to the directory first accesses the web part it will render properly, not only for that user, but any user thereafter.&amp;nbsp; This will happen until the cache is exhausted.&amp;nbsp; So even during the debugging process I was wondering what the heck I just saw a couple of times.&lt;/p&gt;
&lt;p&gt;On the surface the easy solution is to change the permissions and set 'everyone' to have read / write access and move on.&amp;nbsp; What you will notice is that SharePoint will reset these permissions back to the standard after certain events.&amp;nbsp; One of those events is deploying a solution.&amp;nbsp; If you watch the directory you will notice that the bin permissions are recreated when this happens.&amp;nbsp; The bin directory is actually deleted and recreated.&amp;nbsp; So while the 'everyone' account will work temporarily, it isn't a long term solution.&lt;/p&gt;
&lt;p&gt;What about CAS?&amp;nbsp; Doesn't work.&amp;nbsp; Contrary to some of the other posts out there about this this isn't a CAS issue.&amp;nbsp; Granting the assembly 'Full' trust doesn't change the fact that an account that doesn't have access to the directory needs to write to it.&amp;nbsp; While you can set the web.config and disable impersonation or create a CAS policy that doesn't impersonate, this isn't the best solution in cases where you need to impersonate the user.&amp;nbsp; Windows Auth. comes to mind.&amp;nbsp; It would allow you to take the non-impersonated account and add them to one of the built-in groups so the web part would function properly.&amp;nbsp; This probably isn't an acceptable solution if you are an ISV or third party looking to distribute your web part to other parties.&amp;nbsp; They may not be open to adding least privilege accounts to groups on their servers &lt;/p&gt;
&lt;p&gt;One solution that does work is creating a folder in the web application directory and changing the web.config to add a &lt;a href="http://msdn.microsoft.com/en-us/library/823z9h8w.aspx" target="_blank"&gt;probingPath&lt;/a&gt; in order to help the .NET runtime locate your assembly.&amp;nbsp; By creating your own directory you control the permissions and they aren't reset by SharePoint.&amp;nbsp; Your installation and setup are a little more trouble, but you have a solution that should work long term without sacrifices to the functionality of SharePoint or, most importantly, your web part.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9018314" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/Web+Parts/default.aspx">Web Parts</category><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/Embedded+Resources/default.aspx">Embedded Resources</category><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/CAS/default.aspx">CAS</category></item><item><title>Reporting Services: What Happens When I Upgrade</title><link>http://blogs.msdn.com/cliffgreen/archive/2008/09/30/reporting-services-what-happens-when-i-upgrade.aspx</link><pubDate>Tue, 30 Sep 2008 17:03:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8970305</guid><dc:creator>green.cliff</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/cliffgreen/comments/8970305.aspx</comments><wfw:commentRss>http://blogs.msdn.com/cliffgreen/commentrss.aspx?PostID=8970305</wfw:commentRss><description>&lt;p&gt;Recently we were involved in a conversation around upgrading from SSRS 2005 to SSRS 2008.&amp;nbsp; The credit for this post goes to &lt;a href="http://blogs.msdn.com/robertbruckner/" target="_blank"&gt;Robert Bruckner&lt;/a&gt; who guided us during the internal discussion.&amp;nbsp; When you move from SSRS 2005 to SSRS 2008 there are things that happen internally that may be unknown to you.&amp;nbsp;&amp;nbsp; If you upload or deploy your SSRS 2005 reports to an SSRS 2008 server an attempt is made to upgrade the schema to SSRS 2008 RDL.&amp;nbsp; Should that upgrade fail, the report is flagged and an attempt to upgrade will not be made on that report again.&amp;nbsp; The report can still be run by a user, but it will leverage the 2005 processing engine.&lt;/p&gt; &lt;p&gt;If the upgrade is successful we store the original report definition in the database so that you can get to the definition as it existed when deployed.&amp;nbsp; A call to the GetReportDefinition() method or clicking the 'edit' link in Report Manager will return the original RDL file.&amp;nbsp; The upgraded version of the report is stored as a compiled version as a 2008 report in the 2008 RDL.&amp;nbsp; This allows reporting services to leverage this report for rendering when a request is made by the user.&amp;nbsp; It also allows the report to take advantage of the SSRS 2008 features such as on-demand processing.&lt;/p&gt; &lt;p&gt;If you want to upgrade the report prior to uploading to SSRS you will need to open it in Visual Studio 2008 (BIDS) or Report Builder v2, although that capability was not available in the RC1 release.&amp;nbsp; If you would like to figure out which engine is being used to process your report you can leverage the ExecutionLog2 view in the reporting services database.&amp;nbsp; There is a column called AdditionalInfo that has a &amp;lt;ProcessingEngine&amp;gt; element.&amp;nbsp; If that element is set to 2 it means that the 2008 processing engine was used, if set to 1 your report is using the 2005 processing engine.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8970305" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/Reporting+Services/default.aspx">Reporting Services</category></item><item><title>Finding a SharePoint List Template Id</title><link>http://blogs.msdn.com/cliffgreen/archive/2008/08/04/finding-a-sharepoint-list-template-id.aspx</link><pubDate>Mon, 04 Aug 2008 16:11:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8831024</guid><dc:creator>green.cliff</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/cliffgreen/comments/8831024.aspx</comments><wfw:commentRss>http://blogs.msdn.com/cliffgreen/commentrss.aspx?PostID=8831024</wfw:commentRss><description>&lt;p&gt;There are several ways to find out the ID for a List.&amp;nbsp; A typical scenario where a list template id is required is querying a list or set of lists using SPSiteDataQuery.&amp;nbsp; You can find the list template id by looking at the 12\TEMPLATE\FEATURES directory and finding the list in question.&amp;nbsp; Opening the element manifest for the feature you will notice an attribute named DocumentTemplate, which is the List Template ID or Type which will provide the list template type, also ID for the out of box templates.&lt;/p&gt; &lt;div&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #800000"&gt;xml&lt;/span&gt; &lt;span style="color: #ff0000"&gt;version&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="1.0"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;encoding&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="utf-8"&lt;/span&gt; ?&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt; 
&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Elements&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="http://schemas.microsoft.com/sharepoint/"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ListTemplate&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="doclib"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Type&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="101"&lt;/span&gt; 
    &lt;span style="color: #ff0000"&gt;BaseType&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="1"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;OnQuickLaunch&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="TRUE"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;SecurityBits&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="11"&lt;/span&gt; 
    &lt;span style="color: #ff0000"&gt;Sequence&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="110"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;DisplayName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="$Resources:core,doclibList;"&lt;/span&gt; 
    &lt;span style="color: #ff0000"&gt;Description&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="$Resources:core,doclibList_Desc;"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Image&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="/_layouts/images/itdl.gif"&lt;/span&gt; 
    &lt;span style="color: #ff0000"&gt;DocumentTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="101"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt; 
&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Elements&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Another method to do this leveraging the UI is to click Site Actions &amp;gt; Create.&amp;nbsp; The next screen provides a view of all the lists and document libraries that can be created on the site.&amp;nbsp; If you right click the list and select properties you will be presented the Url Address for the list.&amp;nbsp; Highlighting and scrolling to the end of the Url you will see a query string variable called ListTemplate.&amp;nbsp; The value presented is the list template ID.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/cliffgreen/WindowsLiveWriter/FindingaSharePointListTemplateId_7209/image_4.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="212" alt="image" src="http://blogs.msdn.com/blogfiles/cliffgreen/WindowsLiveWriter/FindingaSharePointListTemplateId_7209/image_thumb_1.png" width="358" border="0"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;A more dynamic method of finding this information in code is to leverage the object model.&amp;nbsp; SPWeb has a property called ListTemplates that returns a collection of the lists that can be created on the site.&amp;nbsp; The SPListTemplate class held in the collection has a property called DocumentTemplate property providing the List Template ID. &lt;/p&gt;
&lt;div&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt;( SPSite siteCollection = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SPSite(&lt;span style="color: #006080"&gt;"http://moss.litwareinc.com"&lt;/span&gt;) ) {
  &lt;span style="color: #0000ff"&gt;using&lt;/span&gt;( SPWeb web = siteCollection.OpenWeb() ) {
    &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt;( SPListTemplate template &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; web.ListTemplates ) {
      Console.WriteLine(template.DocumentTemplate.ToString());
    }
  }
}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Another little known method for getting the ID, at least for those features that are out of the box, is to use the feature GUID, which has a format of OOBFxxx-xxxx-xxxx-xxxx-xxxxxxxxx101.&amp;nbsp; For example, the listing for a document library is &lt;strong&gt;00BF&lt;/strong&gt;EA71-E717-4E80-AA17-D0C71B360&lt;strong&gt;101&lt;/strong&gt;.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8831024" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/Features/default.aspx">Features</category></item><item><title>Unravel the SharePoint Threaded Discussion</title><link>http://blogs.msdn.com/cliffgreen/archive/2008/07/16/unravel-the-sharepoint-threaded-discussion.aspx</link><pubDate>Wed, 16 Jul 2008 15:41:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8738337</guid><dc:creator>green.cliff</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/cliffgreen/comments/8738337.aspx</comments><wfw:commentRss>http://blogs.msdn.com/cliffgreen/commentrss.aspx?PostID=8738337</wfw:commentRss><description>&lt;p&gt;The SharePoint Threaded Discussion is a forum type of post.&amp;nbsp; Underneath, like all things SharePoint, it is a list.&amp;nbsp; By default that list is made up of two content types, Discussion and Message.&amp;nbsp; The content types have IDs of 0x012002 and 0x0107 respectively.&amp;nbsp; Following the content type inheritance chain this means that the Discussion content type inherits from folder and the Message content type from Item.&amp;nbsp; This gives us some clue about the structure of the list.&lt;/p&gt; &lt;p&gt;If you enter a top level item in a threaded discussion list it will be created as a folder.&amp;nbsp; In order to navigate each top level thread using the object model we use code similar to that shown below.&lt;/p&gt; &lt;div&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; ( SPSite siteCollection = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SPSite( &lt;span style="color: #006080"&gt;"http://moss.litwareinc.com/"&lt;/span&gt; ) ) {
    &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; ( SPWeb web = siteCollection.OpenWeb( &lt;span style="color: #006080"&gt;"/SiteDirectory/mktg"&lt;/span&gt; ) ) {
        SPList list = web.Lists[&lt;span style="color: #006080"&gt;"Team Discussion"&lt;/span&gt;];

        &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; ( SPListItem folder &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; list.Folders ) {
            Console.WriteLine( &lt;span style="color: #006080"&gt;"-- Folder --"&lt;/span&gt; );
            Console.WriteLine( folder.Title );
            Console.WriteLine( folder.UniqueId.ToString() );
            Console.WriteLine( folder.ID.ToString() );
            Console.WriteLine( folder.Xml );
            Console.WriteLine( &lt;span style="color: #006080"&gt;"-- End Folder --"&lt;/span&gt; );
        }
    }
}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can also iterate over the list items themselves using the typical foreach convention.&amp;nbsp; When you do this take a look at the Xml property for the List Item and you will see various items that we can use to find the context of our item within the threaded discussion.&lt;/p&gt;
&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #800000"&gt;xml&lt;/span&gt; &lt;span style="color: #ff0000"&gt;version&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="1.0"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;encoding&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="utf-8"&lt;/span&gt; ?&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;z:row&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns:z&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='#RowsetSchema'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_ContentTypeId&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='0x010700135BC7419F95B04C8EA15325163C1444'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_Body&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='&amp;amp;lt;div class=ExternalClassAAF51B42E3834F8D90CA3A8DA7739064&amp;amp;gt;&amp;amp;lt;div&amp;amp;gt;second sample item&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;hr&amp;amp;gt;&amp;amp;lt;b&amp;amp;gt;From: &amp;amp;lt;/b&amp;amp;gt;System Account&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;b&amp;amp;gt;Posted: &amp;amp;lt;/b&amp;amp;gt;Wednesday, June 04, 2008 5:14 PM&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;b&amp;amp;gt;Subject: &amp;amp;lt;/b&amp;amp;gt;sample item one&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;div class=ExternalClassF19C451E2C284124AB09D103E8A70A18&amp;amp;gt;&amp;amp;lt;div&amp;amp;gt;first sample item&amp;amp;lt;/div&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_TrimmedBody&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='&amp;amp;lt;div class=ExternalClass4D66DF23C3C649C4985CFE81A1E2E0E2&amp;amp;gt;&amp;amp;lt;div&amp;amp;gt;second sample item&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_ParentFolderId&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='1'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_ContentType&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='Message'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_Modified&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2008-06-04 17:14:33'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_Created&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2008-06-04 17:14:33'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_Author&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='1073741823;#System Account'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_Editor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='1073741823;#System Account'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_owshiddenversion&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='1'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_WorkflowVersion&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='1'&lt;/span&gt;
       &lt;span style="color: #ff0000"&gt;ows__UIVersion&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='512'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows__UIVersionString&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='1.0'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_Attachments&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='0'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows__ModerationStatus&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='0'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_SelectTitle&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_Order&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='200.000000000000'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_GUID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='{8FAC9A20-6343-48A3-8BE3-CD7E17E45894}'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_FileRef&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2;#SiteDirectory/mktg/Lists/TeamDiscussion/sample item one/2_.000'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_FileDirRef&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2;#SiteDirectory/mktg/Lists/Team Discussion/sample item one'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_Last_x0020_Modified&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2;#2008-06-04 17:14:33'&lt;/span&gt;
       &lt;span style="color: #ff0000"&gt;ows_Created_x0020_Date&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2;#2008-06-04 17:14:33'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_FSObjType&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2;#0'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_PermMask&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='0x7fffffffffffffff'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_FileLeafRef&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2;#2_.000'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_UniqueId&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2;#{87C5CD04-7D68-4B26-B00C-DD76AE7B96D8}'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_ProgId&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2;#'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_ScopeId&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2;#{6ED2F3B8-3D0A-4B4F-B092-C9A6D1942AE2}'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows__EditMenuTableStart&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2_.000'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows__EditMenuTableEnd&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2'&lt;/span&gt;
       &lt;span style="color: #ff0000"&gt;ows_LinkFilenameNoMenu&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2_.000'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_LinkFilename&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2_.000'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_ServerUrl&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='/SiteDirectory/mktg/Lists/Team Discussion/sample item one/2_.000'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_EncodedAbsUrl&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='http://moss.litwareinc.com/SiteDirectory/mktg/Lists/Team%20Discussion/sample%20item%20one/2_.000'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_BaseName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2_'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_MetaInfo&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2;#'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows__Level&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='1'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows__IsCurrentVersion&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='1'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_ThreadIndex&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='0x01CA94B8313E972C16929A454ACFA141B2588F7291DB000004B927'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_ShortestThreadIndexIdLookup&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='1;#'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_DiscussionTitleLookup&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='1;#sample item one'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_DiscussionTitle&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='sample item one'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_ReplyNoGif&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='SiteDirectory/mktg/Lists/Team Discussion/sample item one'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_ThreadingControls&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='0x01CA94B8313E972C16929A454ACFA141B2588F7291DB000004B927'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_IndentLevel&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='0x01CA94B8313E972C16929A454ACFA141B2588F7291DB000004B927'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_Indentation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='0x01CA94B8313E972C16929A454ACFA141B2588F7291DB000004B927'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_StatusBar&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2008-06-05T00:14:33Z'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_BodyAndMore&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='&amp;amp;lt;div class=ExternalClassAAF51B42E3834F8D90CA3A8DA7739064&amp;amp;gt;&amp;amp;lt;div&amp;amp;gt;second sample item&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;hr&amp;amp;gt;&amp;amp;lt;b&amp;amp;gt;From: &amp;amp;lt;/b&amp;amp;gt;System Account&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;b&amp;amp;gt;Posted: &amp;amp;lt;/b&amp;amp;gt;Wednesday, June 04, 2008 5:14 PM&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;b&amp;amp;gt;Subject: &amp;amp;lt;/b&amp;amp;gt;sample item one&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;div class=ExternalClassF19C451E2C284124AB09D103E8A70A18&amp;amp;gt;&amp;amp;lt;div&amp;amp;gt;first sample item&amp;amp;lt;/div&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_MessageBody&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='&amp;amp;lt;div class=ExternalClassAAF51B42E3834F8D90CA3A8DA7739064&amp;amp;gt;&amp;amp;lt;div&amp;amp;gt;second sample item&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;hr&amp;amp;gt;&amp;amp;lt;b&amp;amp;gt;From: &amp;amp;lt;/b&amp;amp;gt;System Account&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;b&amp;amp;gt;Posted: &amp;amp;lt;/b&amp;amp;gt;Wednesday, June 04, 2008 5:14 PM&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;b&amp;amp;gt;Subject: &amp;amp;lt;/b&amp;amp;gt;sample item one&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;div class=ExternalClassF19C451E2C284124AB09D103E8A70A18&amp;amp;gt;&amp;amp;lt;div&amp;amp;gt;first sample item&amp;amp;lt;/div&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_BodyWasExpanded&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='{8FAC9A20-6343-48A3-8BE3-CD7E17E45894}'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_QuotedTextWasExpanded&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='{8FAC9A20-6343-48A3-8BE3-CD7E17E45894}'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_CorrectBodyToShow&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='&amp;amp;lt;div class=ExternalClass4D66DF23C3C649C4985CFE81A1E2E0E2&amp;amp;gt;&amp;amp;lt;div&amp;amp;gt;second sample item&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;'&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ows_FullBody&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='&amp;amp;lt;div class=ExternalClassAAF51B42E3834F8D90CA3A8DA7739064&amp;amp;gt;&amp;amp;lt;div&amp;amp;gt;second sample item&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;hr&amp;amp;gt;&amp;amp;lt;b&amp;amp;gt;From: &amp;amp;lt;/b&amp;amp;gt;System Account&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;b&amp;amp;gt;Posted: &amp;amp;lt;/b&amp;amp;gt;Wednesday, June 04, 2008 5:14 PM&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;b&amp;amp;gt;Subject: &amp;amp;lt;/b&amp;amp;gt;sample item one&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;div class=ExternalClassF19C451E2C284124AB09D103E8A70A18&amp;amp;gt;&amp;amp;lt;div&amp;amp;gt;first sample item&amp;amp;lt;/div&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_LimitedBody&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='&amp;amp;lt;div class=ExternalClassAAF51B42E3834F8D90CA3A8DA7739064&amp;amp;gt;&amp;amp;lt;div&amp;amp;gt;second sample item&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;hr&amp;amp;gt;&amp;amp;lt;b&amp;amp;gt;From: &amp;amp;lt;/b&amp;amp;gt;System Account&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;b&amp;amp;gt;Posted: &amp;amp;lt;/b&amp;amp;gt;Wednesday, June 04, 2008 5:14 PM&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;b&amp;amp;gt;Subject: &amp;amp;lt;/b&amp;amp;gt;sample item one&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;br&amp;amp;gt;&amp;amp;lt;div class=ExternalClassF19C451E2C284124AB09D103E8A70A18&amp;amp;gt;&amp;amp;lt;div&amp;amp;gt;first sample item&amp;amp;lt;/div&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_MoreLink&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_LessLink&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_ToggleQuotedText&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_Threading&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='0x01CA94B8313E972C16929A454ACFA141B2588F7291DB000004B927'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_PersonImage&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='System Account'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_PersonViewMinimal&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='System Account'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_IsRootPost&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='0'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_ItemChildCount&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='2;#0'&lt;/span&gt; 
       &lt;span style="color: #ff0000"&gt;ows_ServerRedirected&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='0'&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;One of the more important properties is the &lt;font color="#ff0000"&gt;&lt;font color="#000000"&gt;ows_ParentFolderId&lt;/font&gt;.&lt;/font&gt;&lt;font color="#000000"&gt;&amp;nbsp; By leveraging this property we can establish the parent thread or discussion, in this case the folder, that is the host for the item.&amp;nbsp; This will always be the top level folder item, not the item that was responded to originally.&amp;nbsp; While this does allow you to figure out which items go with which folder, it does not provide order or hierarchy.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;If you examine the default 'Threaded' view that comes with an instance of the Team Discussion you will notice that it contains one column, 'Threading (threaded)'.&amp;nbsp; This column is used for display and also used to sort the items.&amp;nbsp; There is a group of properties that provide a structure that enabling you to figure out he thread hierarchy.&amp;nbsp; Notice the ows_ThreadIndex, ows_Threading, ows_ThreadingControls, ows_IndentLevel, etc.&amp;nbsp; These properties all have the same value for an item, but as you navigate from item to item notice that a hierarchy of sorts is formed.&amp;nbsp; The base item has a thread value and then the children have this same thread value, but with some additional random text after the base item.&amp;nbsp; This begins to form a hierarchy.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;ows_ThreadingIndex='0x01CA94B8313E972C16929A454ACFA141B2588F7291DB’ 
&lt;p&gt;|_ows_ThreadingIndex='0x01CA94B8313E972C16929A454ACFA141B2588F7291DB&lt;font color="#0000ff"&gt;000004B927&lt;/font&gt;' 
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |_ows_ThreadingIndex='0x01CA94B8313E972C16929A454ACFA141B2588F7291DB&lt;font color="#0000ff"&gt;000004B9270000026E29&lt;/font&gt;' 
&lt;p&gt;When reviewing the Xml attributes another item looks promising, ows_Order.&amp;nbsp; It has a format of xxx.xxxxxx.&amp;nbsp; This leads one to believe that this would control the order of the items in the thread.&amp;nbsp; I was hoping to find a pattern that was parent.childorder or something to that affect, but that is not the case.&amp;nbsp; Upon further examination this is simply the item id.&amp;nbsp; It is probably reserved for some future use.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8738337" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/Threaded+Discussion/default.aspx">Threaded Discussion</category></item><item><title>SQL Server 2008 RC0 canonical errors during setup</title><link>http://blogs.msdn.com/cliffgreen/archive/2008/07/07/sql-server-2008-rc0-canonical-errors-during-setup.aspx</link><pubDate>Mon, 07 Jul 2008 16:12:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8701789</guid><dc:creator>green.cliff</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/cliffgreen/comments/8701789.aspx</comments><wfw:commentRss>http://blogs.msdn.com/cliffgreen/commentrss.aspx?PostID=8701789</wfw:commentRss><description>&lt;p&gt;I was installing the RC0 version of SQL Server 2008 this weekend and kept running into the following error:&lt;/p&gt; &lt;p&gt;&lt;em&gt;This access control list is not in canonical form and therefore cannot be modified.&lt;/em&gt; &lt;p&gt;There were a lot of these errors in the Feb CTP related to the registry which seemed to have been resolved.&amp;nbsp; The errors from the RC0 install were related to the directory structure and the permissions being out of order.&lt;/p&gt; &lt;p&gt;I was able to resolve the issue by navigating to the %Program Files%\Microsoft SQL Server\100\Setup Bootstrap\Log\ directory and opening the details.txt file to find out the directory that was having the issue.&amp;nbsp; Using that information I went to the directory, right clicked and went to properties.&amp;nbsp; By clicking the 'Security' tab the OS warns you of the issue and then fixes it.&amp;nbsp; Hitting retry at this point allows the installation to continue.&lt;/p&gt; &lt;p&gt;In total there were 5 directories that caused this issue, all of them located in the %Program Files%\Microsoft SQL Server directory structure.&amp;nbsp; While I didn't capture each of them it is an easy fix that produces a clean install of SQL Server.&amp;nbsp; Hopefully this will save you some time if you are running into the same problem.&amp;nbsp; I was installing on Windows Server 2003 EE R2 SP2.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8701789" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>Creating a 'Link to a Document' Item in a SharePoint Document Library programmatically</title><link>http://blogs.msdn.com/cliffgreen/archive/2008/06/23/creating-a-link-to-a-document-item-in-a-sharepoint-document-library-programmatically.aspx</link><pubDate>Mon, 23 Jun 2008 18:06:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8642401</guid><dc:creator>green.cliff</dc:creator><slash:comments>31</slash:comments><comments>http://blogs.msdn.com/cliffgreen/comments/8642401.aspx</comments><wfw:commentRss>http://blogs.msdn.com/cliffgreen/commentrss.aspx?PostID=8642401</wfw:commentRss><description>&lt;p&gt;One of the new features available in SharePoint 2007 are content types.&amp;nbsp; Content types allow you to classify content to be a particular type.&amp;nbsp; By marking content as a particular content type the metadata, workflow and policies associated with that content type are leveraged instead of default policies that may apply to a standard document.&amp;nbsp; One of the content types available is called 'Link to a Document'.&amp;nbsp; This content type allows you to store a link to a document in a document library instead of the document itself.&amp;nbsp; This comes in handy for documents that are stored in an http(s) referenceable location.&amp;nbsp; When an item is added to a document library and it is classified as a 'Link to a Document' content type an .aspx page is created and stored in the document library as a file.&amp;nbsp; This page is used to redirect the opening of the file to the location where the document link actually resides.&amp;nbsp; The content of the .aspx file is shown below. &lt;/p&gt; &lt;div&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="background-color: #ffff00"&gt;&amp;lt;%@ Assembly Name='Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' %&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #ffff00"&gt;&amp;lt;%@ Register TagPrefix='SharePoint' Namespace='Microsoft.SharePoint.WebControls' Assembly='Microsoft.SharePoint' %&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #ffff00"&gt;&amp;lt;%@ Import Namespace='System.IO' %&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #ffff00"&gt;&amp;lt;%@ Import Namespace='Microsoft.SharePoint' %&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #ffff00"&gt;&amp;lt;%@ Import Namespace='Microsoft.SharePoint.Utilities' %&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #ffff00"&gt;&amp;lt;%@ Import Namespace='Microsoft.SharePoint.WebControls' %&amp;gt;&lt;/span&gt;

&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;html&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns:mso&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="urn:schemas-microsoft-com:office:office"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns:msdt&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Head&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;META&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='progid'&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Content&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='SharePoint.Link'&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color: #008000"&gt;&amp;lt;!--[if gte mso 9]&amp;gt;&amp;lt;xml&amp;gt;&lt;/span&gt;
&lt;span style="color: #008000"&gt;&amp;lt;mso:CustomDocumentProperties&amp;gt;&lt;/span&gt;
&lt;span style="color: #008000"&gt;&amp;lt;mso:URL msdt:dt="string"&amp;gt;http://moss.litwareinc.com/docs/my.xls, http://moss.litwareinc.com/docs/my.xls&amp;lt;/mso:URL&amp;gt;&lt;/span&gt;
&lt;span style="color: #008000"&gt;&amp;lt;mso:ContentType msdt:dt="string"&amp;gt;Link to a Document&amp;lt;/mso:ContentType&amp;gt;&lt;/span&gt;
&lt;span style="color: #008000"&gt;&amp;lt;/mso:CustomDocumentProperties&amp;gt;&lt;/span&gt;
&lt;span style="color: #008000"&gt;&amp;lt;/xml&amp;gt;&amp;lt;![endif]--&amp;gt;&lt;/span&gt;
&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;head&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;body&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;form&lt;/span&gt; &lt;span style="color: #ff0000"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='Form1'&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='server'&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;SharePoint:UrlRedirector&lt;/span&gt; &lt;span style="color: #ff0000"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='Redirector1'&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='server'&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;form&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;body&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;html&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you want to create a 'Link to a Document' item programmatically, you can duplicate this file and replace the following string with the Url that matches the document where you want the item linked.&lt;/p&gt;
&lt;div&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;mso:URL&lt;/span&gt; &lt;span style="color: #ff0000"&gt;msdt:dt&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="string"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;http://moss.litwareinc.com/docs/my.xls, http://moss.litwareinc.com/docs/my.xls&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;mso:URL&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Create a template .txt file for this with the code below so that you can easily replace the url with your content link.&amp;nbsp; Notice the reference to {0}, {0}.&amp;nbsp; This will be used as a string replacement placeholder in the code snippet that will create the item in the document library.&amp;nbsp; In this example I have saved the file locally to the c: drive as linktodocumenttemplate.txt.&lt;/p&gt;
&lt;div&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="background-color: #ffff00"&gt;&amp;lt;%@ Assembly Name='Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' %&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #ffff00"&gt;&amp;lt;%@ Register TagPrefix='SharePoint' Namespace='Microsoft.SharePoint.WebControls' Assembly='Microsoft.SharePoint' %&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #ffff00"&gt;&amp;lt;%@ Import Namespace='System.IO' %&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #ffff00"&gt;&amp;lt;%@ Import Namespace='Microsoft.SharePoint' %&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #ffff00"&gt;&amp;lt;%@ Import Namespace='Microsoft.SharePoint.Utilities' %&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #ffff00"&gt;&amp;lt;%@ Import Namespace='Microsoft.SharePoint.WebControls' %&amp;gt;&lt;/span&gt;

&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;html&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns:mso&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="urn:schemas-microsoft-com:office:office"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns:msdt&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Head&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;META&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='progid'&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Content&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='SharePoint.Link'&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color: #008000"&gt;&amp;lt;!--[if gte mso 9]&amp;gt;&amp;lt;xml&amp;gt;&lt;/span&gt;
&lt;span style="color: #008000"&gt;&amp;lt;mso:CustomDocumentProperties&amp;gt;&lt;/span&gt;
&lt;span style="color: #008000"&gt;&amp;lt;mso:URL msdt:dt="string"&amp;gt;{0}, {0}&amp;lt;/mso:URL&amp;gt;&lt;/span&gt;
&lt;span style="color: #008000"&gt;&amp;lt;mso:ContentType msdt:dt="string"&amp;gt;Link to a Document&amp;lt;/mso:ContentType&amp;gt;&lt;/span&gt;
&lt;span style="color: #008000"&gt;&amp;lt;/mso:CustomDocumentProperties&amp;gt;&lt;/span&gt;
&lt;span style="color: #008000"&gt;&amp;lt;/xml&amp;gt;&amp;lt;![endif]--&amp;gt;&lt;/span&gt;
&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;head&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;body&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;form&lt;/span&gt; &lt;span style="color: #ff0000"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='Form1'&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='server'&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;SharePoint:UrlRedirector&lt;/span&gt; &lt;span style="color: #ff0000"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='Redirector1'&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='server'&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;form&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;body&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;html&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Once you have that file in place the following code snippet can be used to create the item in the document library.&lt;/p&gt;
&lt;div&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; ( SPSite siteCollection = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SPSite( &lt;span style="color: #006080"&gt;"http://moss.litwareinc.com"&lt;/span&gt; ) ) {
    &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; ( SPWeb web = siteCollection.OpenWeb( &lt;span style="color: #006080"&gt;"docs"&lt;/span&gt; ) ) {
        SPList list = web.Lists[&lt;span style="color: #006080"&gt;"Sample"&lt;/span&gt;];

        &lt;span style="color: #008000"&gt;//link to the file&lt;/span&gt;
        &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; fileLinkUrl = &lt;span style="color: #006080"&gt;"http://moss.litwareinc.com/docs/Shared%20Documents/ConfigureIRMinWSS30.doc"&lt;/span&gt;;

        StringBuilder builder = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; StringBuilder();

        &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; ( TextReader reader = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; StreamReader( &lt;span style="color: #006080"&gt;@"C:\linktodocumenttemplate.txt"&lt;/span&gt; ) ) {
            builder.Append( reader.ReadToEnd() );
        }

        &lt;span style="color: #008000"&gt;//replace string template with values&lt;/span&gt;
        builder.Replace( &lt;span style="color: #006080"&gt;"{0}"&lt;/span&gt;, fileLinkUrl );
        
        &lt;span style="color: #008000"&gt;//should change the name of the .aspx file per item&lt;/span&gt;
        SPFile file = list.RootFolder.Files.Add( &lt;span style="color: #006080"&gt;"link_title.aspx"&lt;/span&gt;, UTF8Encoding.UTF8.GetBytes(builder.ToString()));

        &lt;span style="color: #008000"&gt;//set list item properties&lt;/span&gt;
        SPListItem item = file.Item;
        item[&lt;span style="color: #006080"&gt;"Content Type"&lt;/span&gt;] = &lt;span style="color: #006080"&gt;"Link to a Document"&lt;/span&gt;;
        SPFieldUrlValue itemUrl = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SPFieldUrlValue();
        itemUrl.Description = &lt;span style="color: #006080"&gt;"From sample code"&lt;/span&gt;;
        itemUrl.Url = fileLinkUrl;
        item[&lt;span style="color: #006080"&gt;"URL"&lt;/span&gt;] = itemUrl;
        &lt;span style="color: #008000"&gt;//persist changes&lt;/span&gt;
        item.Update();
    }
}&lt;/pre&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8642401" width="1" height="1"&gt;</description></item><item><title>SharePoint Webs web service CreateContentType and UpdateContentType</title><link>http://blogs.msdn.com/cliffgreen/archive/2008/05/30/sharepoint-webs-web-service-createcontenttype-and-updatecontenttype.aspx</link><pubDate>Fri, 30 May 2008 21:44:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8563957</guid><dc:creator>green.cliff</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/cliffgreen/comments/8563957.aspx</comments><wfw:commentRss>http://blogs.msdn.com/cliffgreen/commentrss.aspx?PostID=8563957</wfw:commentRss><description>&lt;p&gt;I was experimenting with the SharePoint Webs web service CreateContentType and UpdateContentType methods recently.&amp;nbsp; The goal was to create a base content type and update it by adding an additional column with a separate web service call.&amp;nbsp; According to the &lt;a href="http://msdn.microsoft.com/en-us/library/webs.webs.updatecontenttype.aspx" target="_blank"&gt;documentation&lt;/a&gt; you are suppose to use the &amp;lt;FieldRefs&amp;gt;&amp;lt;FieldRef /&amp;gt;&amp;lt;/FieldRef&amp;gt; Xml structure to create an XmlNode node and pass into to the method.&amp;nbsp; Well, the documentation is wrong.&amp;nbsp; Thank goodness I ran across this &lt;a href="http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=2186434&amp;amp;SiteID=17&amp;amp;pageid=0#3269769" target="_blank"&gt;post&lt;/a&gt; in the forum which pointed me in the right direction.&lt;/p&gt; &lt;p&gt;The proper Xml structure for the fields is shown below:&lt;/p&gt; &lt;div&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Fields&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Method&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="1"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Field&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="{246D0907-637C-46b7-9AA0-0BB914DAA832}"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="_Author"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;DisplayName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Author"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Hidden&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="FALSE"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Method&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Method&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="1"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Field&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="{038D1503-4629-40f6-ADAF-B47D1AB2D4FE}"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Company"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;DisplayName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Company"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Hidden&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="FALSE"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Method&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Method&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="1"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Field&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="{0FC9CACE-C5C2-465d-AE88-B67F2964CA93}"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="_Category"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;DisplayName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Category"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Hidden&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="FALSE"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Method&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Method&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="1"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Field&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="{1DAB9B48-2D1A-47b3-878C-8E84F0D211BA}"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="_Status"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;DisplayName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Status"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Hidden&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="FALSE"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Method&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Method&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="1"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Field&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="{52578FC3-1F01-4f4d-B016-94CCBCF428CF}"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="_Comments"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;DisplayName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Comments"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Hidden&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="FALSE"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Method&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Fields&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The method ID attribute is an indicator, apparently, on what to do with the field.&amp;nbsp; ID=1 means add it to the content type, ID=2 means update the field and ID=3 indicates you want the field deleted.&amp;nbsp; This seems a bit odd since you are passing a separate XmlNode for newFields in the CreateContentType() method and in the UpdateContentType method passing newFields, updateFields and deleteFields as separate parameters.&amp;nbsp; Shouldn't that be enough to let the method know what to do with each node?&lt;/p&gt;
&lt;p&gt;Hopefully this will save others some time in the future.&amp;nbsp; In the meantime, the documentation needs to be updated properly to reflect the expected structure.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8563957" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/Web+Services/default.aspx">Web Services</category></item><item><title>Adding Web Parts to the Web Part Gallery Using the SharePoint Object Model</title><link>http://blogs.msdn.com/cliffgreen/archive/2008/04/18/adding-web-parts-to-the-web-part-gallery-using-the-sharepoint-object-model.aspx</link><pubDate>Fri, 18 Apr 2008 19:12:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8408230</guid><dc:creator>green.cliff</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/cliffgreen/comments/8408230.aspx</comments><wfw:commentRss>http://blogs.msdn.com/cliffgreen/commentrss.aspx?PostID=8408230</wfw:commentRss><description>&lt;p&gt;Since my &lt;a href="http://blogs.msdn.com/cliffgreen/archive/2008/03/13/removing-web-parts-from-the-my-site-web-part-gallery.aspx"&gt;first&lt;/a&gt; post was based on removing web parts from the web part gallery of a 'My Site' there have been questions about how to add the web parts back should circumstances require it.&amp;nbsp; This is pretty straight-forward, but can get more interesting depending on how robust you want to make the end solution.&amp;nbsp; The Web Part Gallery is a document library that holds a reference to a web part file, either a .dwp or .webpart file.&amp;nbsp; This file is simply a metadata definition of the web part.&amp;nbsp; To add a web part back in the gallery we can leverage the code shown below.&amp;nbsp; This assumes that the web part assembly is installed and the safe control entries are made in the web.config file.&lt;/p&gt; &lt;div&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; IterateWebPartGallery(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; siteCollectionUrl) {
    &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; filePath = &lt;span style="color: #006080"&gt;@"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\PortalLayouts\DWP\owa.dwp"&lt;/span&gt;;

    &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; ( SPSite site = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SPSite( siteCollectionUrl ) ) {
        &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; ( SPWeb web = site.OpenWeb() ) {

            SPList webPartGallery = web.GetCatalog( SPListTemplateType.WebPartCatalog );

            SPFolder folder = webPartGallery.RootFolder;
            &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( folder != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt; ) {
                &lt;span style="color: #0000ff"&gt;byte&lt;/span&gt; [] webPartFile = File.ReadAllBytes(filePath);
                FileInfo webPartFileInfo = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; FileInfo(filePath);

                folder.Files.Add(webPartFileInfo.Name, webPartFile);
                folder.Update();
            }
        }
    }
}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The code gets a reference to the web part gallery in the target site collection by calling the SPWeb.GetCatalog() method.&amp;nbsp; Once we have that reference we get a reference to the root folder of the gallery and call the folder.Files.Add() method to add the web part file.&amp;nbsp; Calling folder.Update() persists this information to the database.&lt;/p&gt;
&lt;p&gt;While this will simply add the file by parsing its contents it won't give us the fine grained control we may want for adding our web part to the gallery.&amp;nbsp; If the file uses resources to define the title and description properties then those get loaded into the gallery "as is" using the method above.&amp;nbsp; This makes our title $Resources:spscore,PeopleWebParts_OWA_Title_Text; and the description $Resources:spscore,PeopleWebParts_OWA_Desc_Text;. &lt;/p&gt;
&lt;p&gt;This can be made a bit more robust by figuring out the title and description from the resource file and setting them in the gallery when the web part is loaded.&amp;nbsp; The SPFolder.Files.Add() method has an overload that accepts a Hashtable reference where we can set additional properties for the web part.&amp;nbsp; The resource values above indicate the resource file is the spscore resource file, spscore.en-US.resx for the en-US culture.&amp;nbsp; Resource files in SharePoint are stored in the \12\Resources directory.&amp;nbsp; I tried to load this file directly using the ResXResourceReader, but received an exception about a missing 'resheader' value in the file.&amp;nbsp; Since .resx files are just Xml I decided to use an XPathNavigator and parse the values out that way.&amp;nbsp; You could also dynamically parse the .webpart or .dwp file to figure out what the associated resx file the web part is referencing, but that is beyond the scope of this post.&amp;nbsp; The final code snippet is shown below.&lt;/p&gt;
&lt;div&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; filePath = &lt;span style="color: #006080"&gt;@"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\PortalLayouts\DWP\owa.dwp"&lt;/span&gt;;
&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; resourceDirectory = &lt;span style="color: #006080"&gt;@"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\Resources"&lt;/span&gt;;

&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; ( SPSite site = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SPSite( siteCollectionUrl ) ) {
    &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; ( SPWeb web = site.OpenWeb() ) {

        SPList webPartGallery = web.GetCatalog( SPListTemplateType.WebPartCatalog );

        &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; title = &lt;span style="color: #006080"&gt;""&lt;/span&gt;;
        &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; description = &lt;span style="color: #006080"&gt;""&lt;/span&gt;;

        XPathDocument xml = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; XPathDocument( File.Open( Path.Combine( resourceDirectory, &lt;span style="color: #006080"&gt;"spscore.en-US.resx"&lt;/span&gt; ), FileMode.Open, FileAccess.Read ) );
        XPathNavigator navigator = xml.CreateNavigator();
        &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; xpathExpression = &lt;span style="color: #006080"&gt;"/root/Data[@Name='{0}']/Value"&lt;/span&gt;;
        XPathNavigator node = navigator.SelectSingleNode( &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;.Format( xpathExpression, &lt;span style="color: #006080"&gt;"PeopleWebParts_OWA_Title_Text"&lt;/span&gt; ) );
        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; ( node != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt; ) {
            title = node.Value;
        }
        node = navigator.SelectSingleNode( &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;.Format( xpathExpression, &lt;span style="color: #006080"&gt;"PeopleWebParts_OWA_Desc_Text"&lt;/span&gt; ) );
        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; ( node != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt; ) {
            description = node.Value;
        }


        SPFolder folder = webPartGallery.RootFolder;
        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; ( folder != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt; ) {
            &lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;[] webPartFile = File.ReadAllBytes( filePath );
            FileInfo webPartFileInfo = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; FileInfo( filePath );

            Hashtable properties = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Hashtable();
            properties.Add( &lt;span style="color: #006080"&gt;"Title"&lt;/span&gt;, title );
            properties.Add( &lt;span style="color: #006080"&gt;"WebPartDescription"&lt;/span&gt;, description );
            properties.Add( &lt;span style="color: #006080"&gt;"Group"&lt;/span&gt;, &lt;span style="color: #006080"&gt;"Outlook Web Access"&lt;/span&gt; );


            folder.Files.Add( webPartFileInfo.Name, webPartFile, properties );
            folder.Update();
        }
    }
}&lt;/pre&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8408230" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://blogs.msdn.com/cliffgreen/archive/tags/Web+Parts/default.aspx">Web Parts</category></item></channel></rss>