<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.imason.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>Rez's spot : SharePoint, technical</title><link>http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/tags/SharePoint/technical/default.aspx</link><description>Tags: SharePoint, technical</description><dc:language>en</dc:language><generator>Telligent Evolution 5.0 (Build: 40623.6204)</generator><item><title>Event ID: 6875 in Event Viewer after deleting an SPFolder in a SharePoint document library</title><link>http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/2009/05/14/event-id-6875-in-event-viewer-after-deleting-an-spfolder-in-a-sharepoint-document-library.aspx</link><pubDate>Thu, 14 May 2009 22:20:00 GMT</pubDate><guid isPermaLink="false">ba1d72eb-a51c-4157-8cec-718d26de3334:1334</guid><dc:creator>Noorez Khamis</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.imason.com/imason_Blogs/b/noorez_khamis/rsscomments.aspx?WeblogPostID=1334</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.imason.com/imason_Blogs/b/noorez_khamis/commentapi.aspx?WeblogPostID=1334</wfw:comment><comments>http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/2009/05/14/event-id-6875-in-event-viewer-after-deleting-an-spfolder-in-a-sharepoint-document-library.aspx#comments</comments><description>&lt;p&gt;ehucsd969j&lt;/p&gt;
&lt;p&gt;I am deleting a folder from a document library using the code:&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;using (SPSite tempDocLibSite = new SPSite(tempDocLibWebRootUrl))
{
    using (SPWeb tempDocLibWeb = tempDocLibSite.OpenWeb())
    {
        tempDocLibWeb.AllowUnsafeUpdates = true;

        SPFolder tempAttachmentSubFolder = tempDocLibWeb.GetFolder(string.Format(&amp;quot;{0}/{1}/{2}&amp;quot;, 
            tempDocLibName, base.ListId.ToString(), hdnTempAttachmentID.Value));

        &lt;span style="text-decoration:underline;"&gt;&lt;span style="color:#ff0000;"&gt;tempAttachmentSubFolder.Delete();&lt;/span&gt;&lt;/span&gt;

        tempDocLibWeb.Update();

        tempDocLibWeb.AllowUnsafeUpdates = false;
    }
}&lt;/pre&gt;
&lt;p&gt;When it get&amp;rsquo;s to the highlighted line, I get the following error in the event viewer with Event ID: 6875:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Error loading and running event receiver Microsoft.SharePoint.Publishing.Internal.PublishingWebEventReceiver in Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c. Additional information is below. &lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;: There is no file with URL &amp;#39;TempAttachmentsUpload/e4486bd9-1719-4a9d-a8a1-de25924cd49a/0136561e-0d20-4b0d-b7e7-ab1e1ada6218&amp;#39; in this Web. &lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The funny thing is that the folder &lt;strong&gt;&lt;em&gt;does&lt;/em&gt;&lt;/strong&gt; exist and &lt;strong&gt;&lt;em&gt;does&lt;/em&gt;&lt;/strong&gt; get deleted.&lt;/p&gt;
&lt;p&gt;There are lots of resources on the web about this event id for SharePoint but it looks like it&amp;rsquo;s an event that is very common for different reasons.&lt;/p&gt;
&lt;p&gt;I am using MOSS SP1 with the December Cumulative Updates.&lt;/p&gt;
&lt;p&gt;It looks like there is a built-in event receiver that is executing when the folder gets deleted which is causing this error.&amp;nbsp; I don&amp;rsquo;t think it should cause this error and it looks like it&amp;rsquo;s a bug, hopefully someone can confirm it or correct my code.&amp;nbsp; I&amp;rsquo;m not sure if it is fixed in SP2 or the April Cumulative Updates though.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;[1] &lt;a rel="me" href="http://technorati.com/claim/ehucsd969j"&gt;Technorati Profile&lt;/a&gt; &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.imason.com/aggbug.aspx?PostID=1334" width="1" height="1"&gt;</description><category domain="http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/tags/technical/default.aspx">technical</category></item><item><title>Deploying Windows Media Server in a Single Server deployment and Pointing it to a directory of Media Files</title><link>http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/2009/04/23/deploying-windows-media-server-in-a-single-server-deployment-and-pointing-it-to-a-directory-of-media-files.aspx</link><pubDate>Thu, 23 Apr 2009 19:46:00 GMT</pubDate><guid isPermaLink="false">ba1d72eb-a51c-4157-8cec-718d26de3334:1272</guid><dc:creator>Noorez Khamis</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.imason.com/imason_Blogs/b/noorez_khamis/rsscomments.aspx?WeblogPostID=1272</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.imason.com/imason_Blogs/b/noorez_khamis/commentapi.aspx?WeblogPostID=1272</wfw:comment><comments>http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/2009/04/23/deploying-windows-media-server-in-a-single-server-deployment-and-pointing-it-to-a-directory-of-media-files.aspx#comments</comments><description>&lt;p&gt;On my SharePoint server, I have a media directory (i.e. c:\media) full of media files that I needed to stream on the web via a SharePoint Media Player Web Part that I created (similar to [1]).&amp;nbsp;&amp;nbsp; At first, I just pointed an IIS virtual directory to that directory (i.e. http://&amp;lt;myserver&amp;gt;/media) and configured my web part to point to the file via the virtual directory (i.e. http://&amp;lt;myserver&amp;gt;/media/myfile.avi).&lt;/p&gt;
&lt;p&gt;This is called&lt;strong&gt; Web Server Streaming&lt;/strong&gt; and was &lt;strong&gt;&lt;em&gt;terribly choppy and slow&lt;/em&gt;&lt;/strong&gt;, you can see more details on this type of streaming at [2].&lt;/p&gt;
&lt;p&gt;I then decided to deploy Windows Media Services on my Win 2K3 Server (ensure you have SP2 installed).&amp;nbsp; I wanted to get it up and running really fast so I used a Single Server deployment.&amp;nbsp; Getting this up and running turned out to be quite easy and very fast to configure.&amp;nbsp; Instructions are below to get this set up.&lt;/p&gt;
&lt;p&gt;The end results were that I configured my SharePoint Media Web Part to point to this location via a URL similar to &lt;strong&gt;&lt;em&gt;mms://&amp;lt;servername&amp;gt;/&amp;lt;publishingpointname&amp;gt;/filename&lt;/em&gt;&lt;/strong&gt; and the streaming was &lt;strong&gt;&lt;em&gt;still&lt;/em&gt;&lt;/strong&gt; a little bit choppy and slow but a little better than using a web server.&amp;nbsp; When I play through window media player itself, it&amp;rsquo;s actually very smooth.&amp;nbsp; I&amp;rsquo;m going to see if there is some configuration in my SharePoint Media Player Web Part that that I can tweak to make make it stream better as a next step.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="color:#ff0000;"&gt;**Update**&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Turns out that the reason it was choppy was because in my SharePoint Media Player Web Part, I had the object and embed parameters incorrect, furthermore, the line windowlessvideo=&amp;rdquo;1&amp;rdquo; in my &amp;lt;embed&amp;gt; tag caused the control not to render in firefox.&amp;nbsp; As soon as I removed it and fixed the formatting, smooth video playing ensued!&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;&amp;lt;OBJECT id=&amp;quot;ctl00$ctl14&amp;quot; width=&amp;quot;480&amp;quot; height=&amp;quot;270&amp;quot; &lt;br /&gt;    CLASSID=&amp;quot;CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6&amp;quot; &lt;br /&gt;    type=&amp;quot;application/x-oleobject&amp;quot; &lt;br /&gt;    codebase=&amp;quot;http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902&amp;quot; &lt;br /&gt;    standby=&amp;quot;Loading Microsoft Windows Media Player components...&amp;quot; &lt;br /&gt;    align=&amp;quot;middle&amp;quot; &amp;gt;&lt;br /&gt;    &amp;lt;PARAM NAME=&amp;quot;FILENAME&amp;quot; VALUE=&amp;quot;mms://myserver/myfilepath.wmv&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;PARAM NAME=&amp;quot;AutoStart&amp;quot; VALUE=&amp;quot;False&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;PARAM NAME=&amp;quot;z-index&amp;quot; VALUE=&amp;quot;-1&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;PARAM NAME=&amp;quot;AutoRewind&amp;quot; VALUE=&amp;quot;True&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;PARAM NAME=&amp;quot;SendOpenStateChangeEvents&amp;quot; VALUE=&amp;quot;True&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;PARAM NAME=&amp;quot;ShowControls&amp;quot; VALUE=&amp;quot;True&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;PARAM NAME=&amp;quot;ShowTracker&amp;quot; VALUE=&amp;quot;True&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;PARAM NAME=&amp;quot;showstatusbar&amp;quot; value=&amp;quot;True&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;PARAM NAME=&amp;quot;DefaultFrame&amp;quot; value=&amp;quot;Slide&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;PARAM NAME=&amp;quot;enablecontextmenu&amp;quot; value=&amp;quot;True&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;PARAM NAME=&amp;quot;TransparentAtStart&amp;quot; value=&amp;quot;True&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;PARAM NAME=&amp;quot;TransparentOnStop&amp;quot; value=&amp;quot;True&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;PARAM NAME=&amp;quot;showPositionControls&amp;quot; value=&amp;quot;True&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;EMBED type=&amp;quot;application/x-mplayer2&amp;quot; &lt;br /&gt;        PLUGINSPAGE=&amp;quot;http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/&amp;quot; &lt;br /&gt;        QUALITY=&amp;quot;high&amp;quot; &lt;br /&gt;        SRC=&amp;quot;mms://myserver/myfilepath.wmv&amp;quot; &lt;br /&gt;        AUTOSTART=&amp;quot;False&amp;quot; &lt;br /&gt;        SHOWCONTROLS=&amp;quot;True&amp;quot; &lt;br /&gt;        SHOWSTATUSBAR=&amp;quot;True&amp;quot; &lt;br /&gt;        SHOWPOSITIONCONTROLS=&amp;quot;True&amp;quot; &lt;br /&gt;        SHOWTRACKER=&amp;quot;True&amp;quot; &lt;br /&gt;        ENABLECONTEXTMENU=&amp;quot;True&amp;quot; &lt;br /&gt;        WIDTH=&amp;quot;480&amp;quot; &lt;br /&gt;        HEIGHT=&amp;quot;270&amp;quot; &lt;br /&gt;       &lt;span style="color:#ff0000;"&gt;&lt;strong&gt;&lt;em&gt; WINDOWLESSVIDEO=&amp;quot;1&amp;quot;&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt; &amp;lt;!&amp;mdash;Remove this--&amp;gt;&lt;br /&gt;        ALIGN=&amp;quot;middle&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;/EMBED&amp;gt;&lt;br /&gt;&amp;lt;/OBJECT&amp;gt;&lt;/pre&gt;
&lt;h4&gt;Single Server Deployment&amp;nbsp; Description [3]&lt;/h4&gt;
&lt;p&gt;In a single-server deployment, one Windows Media server works with one or more encoders to stream content to a small group of clients. The configuration might look like this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.imason.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/noorez_5F00_khamis/image_5F00_42100176.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.imason.com/resized-image.ashx/__size/500x0/__key/CommunityServer.Blogs.Components.WeblogFiles/00.00.00.00.28/0027.image_5F00_5F00_5F00_42100176.png" border="0" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;The single-server update is easiest because you only run through the process once. Ideally, you would have a spare computer on which you can perform a clean installation of Windows Server 2003 or Windows Server 2008 and Windows Media Services. This is beneficial because you can keep your existing server in production until all installation and testing of the new server is complete, minimizing service disruption for your viewers. &lt;br /&gt;If you do not have a spare computer, then be sure to make a backup of the entire system. Then choose a period where you experience low traffic on your site and proceed with the update as described later in this document.&lt;/p&gt;
&lt;h4&gt;Deployment instructions&lt;/h4&gt;
&lt;h5&gt;Step 1:&lt;/h5&gt;
&lt;p&gt;Install Windows Media Services from Control Panel --&amp;gt; Add/Remove Programs --&amp;gt; Add/Remove Windows Components&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.imason.com/resized-image.ashx/__size/550x0/__key/CommunityServer.Blogs.Components.WeblogFiles/00.00.00.00.28/1817.clip_5F00_image003_5F00_45AE1C53.jpg" border="0" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.imason.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/00.00.00.00.28/7752.image_5F00_5F00_5F00_42100176.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.imason.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/noorez_5F00_khamis/clip_5F00_image003_5F00_45AE1C53.jpg"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h5&gt;Step 2:&lt;/h5&gt;
&lt;p&gt;&lt;a href="http://www.imason.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/00.00.00.00.28/1680.clip_5F00_image003_5F00_45AE1C53.jpg"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Go to Start -&amp;gt; Admin Tools -&amp;gt; Windows Media Services &lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.imason.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/noorez_5F00_khamis/image_5F00_25930F96.png"&gt;&lt;/a&gt;&lt;img src="http://www.imason.com/resized-image.ashx/__size/550x0/__key/CommunityServer.Blogs.Components.WeblogFiles/00.00.00.00.28/4645.image_5F00_25930F96.png" border="0" alt="" /&gt;&amp;nbsp;&lt;/p&gt;
&lt;h5&gt;Step 3:&lt;/h5&gt;
&lt;p&gt;Go to Getting Started tab --&amp;gt; Test My Server &amp;ndash;&amp;gt; Say Yes to allow client connections to test the server and ensure it works&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.imason.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/noorez_5F00_khamis/image_5F00_5A336BD1.png"&gt;&lt;/a&gt;&lt;img src="http://www.imason.com/resized-image.ashx/__size/550x0/__key/CommunityServer.Blogs.Components.WeblogFiles/00.00.00.00.28/3678.image_5F00_5A336BD1.png" border="0" alt="" /&gt;&amp;nbsp;&lt;/p&gt;
&lt;h5&gt;Step 4:&lt;/h5&gt;
&lt;p&gt;Add a new Publishing Point (Advanced)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.imason.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/noorez_5F00_khamis/image_5F00_32F9229C.png"&gt;&lt;/a&gt;&lt;img src="http://www.imason.com/resized-image.ashx/__size/550x0/__key/CommunityServer.Blogs.Components.WeblogFiles/00.00.00.00.28/6724.image_5F00_5F00_5F00_32F9229C.png" border="0" alt="" /&gt;&amp;nbsp;&lt;/p&gt;
&lt;h5&gt;Step 5:&lt;/h5&gt;
&lt;p&gt;Select:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;On-demand Publishing Point type &lt;/li&gt;
&lt;li&gt;Give it a name &lt;/li&gt;
&lt;li&gt;Point to the file-share where the media will be streamed from &lt;/li&gt;
&lt;li&gt;Select Directory content type &lt;a href="http://www.imason.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/00.00.00.00.28/5672.image_5F00_00954F1D.png"&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href="http://www.imason.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/noorez_5F00_khamis/image_5F00_00954F1D.png"&gt;&lt;/a&gt;&amp;nbsp;&lt;img src="http://www.imason.com/resized-image.ashx/__size/550x0/__key/CommunityServer.Blogs.Components.WeblogFiles/00.00.00.00.28/5672.image_5F00_00954F1D.png" border="0" alt="" /&gt;&lt;/p&gt;
&lt;h5&gt;Step 6:&lt;/h5&gt;
&lt;p&gt;Go to Source tab and test a media file in that directory.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.imason.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/noorez_5F00_khamis/image_5F00_797612A4.png"&gt;&lt;/a&gt;&lt;img src="http://www.imason.com/resized-image.ashx/__size/550x0/__key/CommunityServer.Blogs.Components.WeblogFiles/00.00.00.00.28/0878.image_5F00_797612A4.png" border="0" alt="" /&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As you can see, we now are able to stream all the files in that directory using the path:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;mms://&amp;lt;servername&amp;gt;/&amp;lt;publishing point name&amp;gt;/&amp;lt;media file path&amp;gt; &lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;where:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;mms://&amp;lt;servername&amp;gt;/&amp;lt;publishing point name&amp;gt; &lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;is the &amp;ldquo;&lt;em&gt;location of content&lt;/em&gt;&amp;rdquo; directory on the local media server.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;[1] &lt;a href="http://www.sharepointblogs.com/ajp/archive/2007/07/18/media-player.aspx"&gt;http://www.sharepointblogs.com/ajp/archive/2007/07/18/media-player.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;[2] &lt;a href="http://www.microsoft.com/windows/windowsmedia/howto/articles/introhosting.aspx" title="http://www.microsoft.com/windows/windowsmedia/howto/articles/introhosting.aspx"&gt;http://www.microsoft.com/windows/windowsmedia/howto/articles/introhosting.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;[3]&amp;nbsp; &lt;a href="http://www.microsoft.com/windows/windowsmedia/howto/articles/upgradewms9s.aspx#singleserver" title="http://www.microsoft.com/windows/windowsmedia/howto/articles/upgradewms9s.aspx#singleserver"&gt;http://www.microsoft.com/windows/windowsmedia/howto/articles/upgradewms9s.aspx#singleserver&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.imason.com/aggbug.aspx?PostID=1272" width="1" height="1"&gt;</description><category domain="http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/tags/technical/default.aspx">technical</category><category domain="http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/tags/deployment/default.aspx">deployment</category></item><item><title>Unable to add SharePoint event handler to the same list OnSaveChange() in a custom field type</title><link>http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/2009/04/20/unable-to-add-sharepoint-event-handler-to-the-same-list-onsavechange-in-a-custom-field-type.aspx</link><pubDate>Mon, 20 Apr 2009 22:30:10 GMT</pubDate><guid isPermaLink="false">ba1d72eb-a51c-4157-8cec-718d26de3334:1265</guid><dc:creator>Noorez Khamis</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.imason.com/imason_Blogs/b/noorez_khamis/rsscomments.aspx?WeblogPostID=1265</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.imason.com/imason_Blogs/b/noorez_khamis/commentapi.aspx?WeblogPostID=1265</wfw:comment><comments>http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/2009/04/20/unable-to-add-sharepoint-event-handler-to-the-same-list-onsavechange-in-a-custom-field-type.aspx#comments</comments><description>&lt;p&gt;I haven’t found any information on this but today I tried to add a custom event handler to a list automatically when a custom field type is added to a list using the OnSaveChange() method and I got the following error:&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;The specified program requires a newer version of Windows. (Exception from HRESULT: 0x8007047E)   at Microsoft.SharePoint.Library.SPRequestInternalClass.AddField(String bstrUrl, String bstrListName, String bstrSchemaXml, Int32 grfAdd) 
   at Microsoft.SharePoint.Library.SPRequest.AddField(String bstrUrl, String bstrListName, String bstrSchemaXml, Int32 grfAdd) &lt;/pre&gt;

&lt;p&gt;This message doesn’t seem to be much help but what I think is happening is that SharePoint isn’t allowing simultaneous changes to a list using different SPWeb/SpSite objects.&amp;#160; Here is a break down of my problem:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;I created a custom field type that has custom configuration properties&lt;/li&gt;

  &lt;li&gt;I created my own property edit control using the IFieldEditor Interface [1]&lt;/li&gt;

  &lt;li&gt;Once the user hits OK to save the custom field to the list, it calls the OnSaveChange() method automatically&lt;/li&gt;

  &lt;li&gt;In this OnSaveChange() method, I not only save my custom properties [2] but I also try to add an event handler to that same list using a new SPSite/SPWeb/SPList object [3].&lt;/li&gt;

  &lt;li&gt;It throws the error above&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The way I was able to fix this was that instead of creating my own SPSite/SPWeb and SPList objects use the SPField object that is passed to the OnSaveChange(SPField field, bool isNewField) method and accessing the list to be updated (with the event handler) by calling the field.ParentList object:&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;public void OnSaveChange(SPField field, bool isNewField)&lt;br /&gt;{&lt;br /&gt;    try&lt;br /&gt;    {&lt;br /&gt;        SPSecurity.RunWithElevatedPrivileges(&lt;br /&gt;            delegate()&lt;br /&gt;            {&lt;br /&gt;                #region Delete Existing deleting event handlers first&lt;br /&gt;&lt;br /&gt;                SPEventReceiverDefinitionCollection evrs = &lt;/pre&gt;

&lt;pre class="brush: csharp;"&gt;                       field.ParentList.EventReceivers;&lt;br /&gt;                List&amp;lt;Guid&amp;gt; ersToDelete = new List&amp;lt;Guid&amp;gt;();&lt;br /&gt;&lt;br /&gt;                foreach (SPEventReceiverDefinition er in evrs)&lt;br /&gt;                {&lt;br /&gt;                    if (er.Type == SPEventReceiverType.ItemDeleting)&lt;br /&gt;                        ersToDelete.Add(er.Id);&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                if (evrs.Count &amp;gt; 0)&lt;br /&gt;                {&lt;br /&gt;                    foreach (Guid i in ersToDelete)&lt;br /&gt;                    {&lt;br /&gt;                        evrs[i].Delete();&lt;br /&gt;                        field.ParentList.Update();&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                #endregion&lt;br /&gt;&lt;br /&gt;                string assembly = Assembly.GetExecutingAssembly().FullName;&lt;br /&gt;                string className = typeof(DeleteIconEventHandler).FullName;&lt;br /&gt;&lt;br /&gt;                field.ParentList.EventReceivers.Add(&lt;/pre&gt;

&lt;pre class="brush: csharp;"&gt;                    SPEventReceiverType.ItemDeleting, assembly, className);&lt;br /&gt;                field.ParentList.Update();&lt;br /&gt;&lt;br /&gt;            });&lt;br /&gt;    }&lt;br /&gt;    catch (Exception ex)&lt;br /&gt;    {&lt;br /&gt;        string message = string.Format(&amp;quot;ERROR: Method {0} had an exception while &lt;/pre&gt;

&lt;pre class="brush: csharp;"&gt;            attempting RegisterDeleteItemEventHandler : {0}&amp;quot;, ex.Message);&lt;br /&gt;        throw new SPException(message);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;[1] &lt;a title="http://msdn.microsoft.com/en-us/library/bb802857.aspx" href="http://msdn.microsoft.com/en-us/library/bb802857.aspx"&gt;http://msdn.microsoft.com/en-us/library/bb802857.aspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;[2] &lt;a title="http://www.sharepointblogs.com/aaronrh/archive/2007/05/25/the-solution-to-saving-properties-in-custom-field-types.aspx" href="http://www.sharepointblogs.com/aaronrh/archive/2007/05/25/the-solution-to-saving-properties-in-custom-field-types.aspx"&gt;http://www.sharepointblogs.com/aaronrh/archive/2007/05/25/the-solution-to-saving-properties-in-custom-field-types.aspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;[3] &lt;a title="http://fredmorrison.wordpress.com/category/uncategorized/" href="http://fredmorrison.wordpress.com/category/uncategorized/"&gt;http://fredmorrison.wordpress.com/category/uncategorized/&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.imason.com/aggbug.aspx?PostID=1265" width="1" height="1"&gt;</description><category domain="http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/tags/technical/default.aspx">technical</category></item><item><title>Access default Project Resources.resx from web controls in SharePoint</title><link>http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/2009/04/20/access-default-project-resources-resx-from-web-controls-in-sharepoint.aspx</link><pubDate>Mon, 20 Apr 2009 20:55:00 GMT</pubDate><guid isPermaLink="false">ba1d72eb-a51c-4157-8cec-718d26de3334:1264</guid><dc:creator>Noorez Khamis</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.imason.com/imason_Blogs/b/noorez_khamis/rsscomments.aspx?WeblogPostID=1264</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.imason.com/imason_Blogs/b/noorez_khamis/commentapi.aspx?WeblogPostID=1264</wfw:comment><comments>http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/2009/04/20/access-default-project-resources-resx-from-web-controls-in-sharepoint.aspx#comments</comments><description>&lt;p&gt;I struggled with this problem all day today.&amp;nbsp; Here is my scenario:&lt;/p&gt;
&lt;p&gt;I have created a&amp;nbsp; custom SharePoint rendering template which has a bit of JavaScript in it.&amp;nbsp; In the JavaScript, I want to access a string value in the Resource.resx file that is embedded to my assembly that I&amp;rsquo;m signing with a strong name and deploying to the GAC:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.imason.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/noorez_5F00_khamis/image_5F00_384234C8.png"&gt;&lt;/a&gt;&lt;img src="http://www.imason.com/resized-image.ashx/__size/550x0/__key/CommunityServer.Blogs.Components.WeblogFiles/00.00.00.00.28/3441.image_5F00_384234C8.png" border="0" alt="" /&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In my code, I can easily access the string via:&lt;/p&gt;
&lt;pre&gt;string myString = MyProjectNamespace.Properties.Resources.StringIWantToAccess&lt;/pre&gt;
&lt;p&gt;What I want to do is access that resource string from my custom .ascx web control itself which is a SharePoint rendering template that sits in the controltemplates directory.&amp;nbsp; I don&amp;rsquo;t want to put my .resx resources in App_GlobalResources or App_LocalResources either.&amp;nbsp; I have tried&amp;nbsp;using &amp;lt;%$ Resources:StringIWantToAccess %&amp;gt;&amp;quot; /&amp;gt;&amp;nbsp; and &amp;lt;%$ Resources:AssemblyName, StringIWantToAccess %&amp;gt;&amp;quot; /&amp;gt; but had no luck with this with all sorts of combinations.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;It doesn&amp;rsquo;t seem that SharePoint was be able to find the resources automatically because the .ascx file is not running under the context of my custom assembly code but rather of&amp;nbsp;SharePoint.&lt;/p&gt;
&lt;p&gt;I was finally able to get it working by the following:&lt;/p&gt;
&lt;p&gt;1.&amp;nbsp;&amp;nbsp; In my .ascx file reference the resource using the following code:&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;&amp;lt;% =MyProjectNamespace.Properties.Resources.StringIWantToAccess %&amp;gt;&lt;/pre&gt;
&lt;p&gt;2.&amp;nbsp;&amp;nbsp; Add a reference to my assembly on the .ascx file&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;&amp;lt;%@ Assembly Name=&amp;quot;myAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b694fe5cf34f8401&amp;quot; %&amp;gt;&lt;/pre&gt;
&lt;p&gt;3.&amp;nbsp;&amp;nbsp; Change the Access Modifier to allow Public access &lt;img src="http://www.imason.com/resized-image.ashx/__size/550x0/__key/CommunityServer.Blogs.Components.WeblogFiles/00.00.00.00.28/1803.image_5F00_1C3175DD.png" border="0" style="float:left;" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.imason.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/noorez_5F00_khamis/image_5F00_1C3175DD.png"&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.imason.com/aggbug.aspx?PostID=1264" width="1" height="1"&gt;</description><category domain="http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/tags/Resources/default.aspx">Resources</category><category domain="http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/tags/technical/default.aspx">technical</category></item><item><title>SharePoint Custom List Form Error - Input string was not in a correct format</title><link>http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/2009/04/16/sharepoint-custom-list-form-error-input-string-was-not-in-a-correct-format.aspx</link><pubDate>Thu, 16 Apr 2009 22:41:00 GMT</pubDate><guid isPermaLink="false">ba1d72eb-a51c-4157-8cec-718d26de3334:1252</guid><dc:creator>Noorez Khamis</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.imason.com/imason_Blogs/b/noorez_khamis/rsscomments.aspx?WeblogPostID=1252</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.imason.com/imason_Blogs/b/noorez_khamis/commentapi.aspx?WeblogPostID=1252</wfw:comment><comments>http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/2009/04/16/sharepoint-custom-list-form-error-input-string-was-not-in-a-correct-format.aspx#comments</comments><description>&lt;p&gt;I&amp;rsquo;m not sure why this happens but here is the scenario:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open SharePoint Designer and create your own edit form following instructions [1] (i.e. copy EditForm.aspx to MyEditForm.aspx) &lt;/li&gt;
&lt;li&gt;Apply the MS Hot Fix that allows attachments on custom edit forms [2] &lt;/li&gt;
&lt;li&gt;Hit the save button &lt;/li&gt;
&lt;li&gt;Quickly browse to that page in a browser (i.e. &lt;a href="http://mysharepointsite/lists/mylist/MyEditForm.aspx"&gt;http://mysharepointsite/lists/mylist/MyEditForm.aspx&lt;/a&gt;) &lt;/li&gt;
&lt;li&gt;You get an error similar to: &lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;[FormatException: Input string was not in a correct format.] 
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&amp;amp; number, NumberFormatInfo info, Boolean parseDecimal) +7467367 
System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119 
System.Convert.ToInt32(String value, IFormatProvider provider) +48 
Microsoft.SharePoint.SPListItem.ValueFromSafeArrayObject(Object obj, SPField fld) +785 
Microsoft.SharePoint.SPListItem.GetValue(SPField fld, Int32 columnNumber, Boolean bRaw) +768 
Microsoft.SharePoint.SPListItem.GetValue(String strName, Boolean bThrowException) +111 
Microsoft.SharePoint.SPListItem.GetValue(String strName) +39 
Microsoft.SharePoint.SPListItem.AddOrUpdateItem(Boolean bAdd, Boolean bSystem, Boolean bPreserveItemVersion, Boolean bNoVersion, Boolean bMigration, Boolean bPublish, Boolean bCheckOut, Boolean bCheckin, Guid newGuidOnAdd, Int32&amp;amp; ulID, Object&amp;amp; objAttachmentNames, Object&amp;amp; objAttachmentContents, Boolean suppressAfterEvents) +1228 
Microsoft.SharePoint.SPListItem.UpdateInternal(Boolean bSystem, Boolean bPreserveItemVersion, Guid newGuidOnAdd, Boolean bMigration, Boolean bPublish, Boolean bNoVersion, Boolean bCheckOut, Boolean bCheckin, Boolean suppressAfterEvents) +166&lt;/pre&gt;
&lt;p&gt;After a few hours of debugging through my code and trying out other people&amp;rsquo;s ideas [3], it turns out that it doesn&amp;rsquo;t have anything to do with my code.&lt;/p&gt;
&lt;p&gt;What I found was that if you wait a few minutes and browse to the newly created form again, you don&amp;rsquo;t get the error.&amp;nbsp; It looks like once you save the file in SharePoint Designer, it takes a few minutes to propagate the page through the content database. If you browse to the page before this propagation is finished, you get the error &amp;ldquo;Input String was not in a correct format.&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="color:#ff0000;"&gt;***Update***&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;It looks like I was still having this problem even after waiting a few minutes.&amp;nbsp; I was now getting:&lt;/p&gt;
&lt;pre&gt;[FormatException: Input string was not in a correct format.]
   System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&amp;amp; number, NumberFormatInfo info, Boolean parseDecimal) +7469351
   System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119
   System.Convert.ToInt32(String value, IFormatProvider provider) +48
   Microsoft.SharePoint.WebControls.ItemHiddenVersion.OnLoad(EventArgs e) +293
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627&lt;/pre&gt;
&lt;p&gt;So I started digging around in reflector to see what was going on in that control:&lt;/p&gt;
&lt;pre&gt;    // Methods
    [SharePointPermission(SecurityAction.Demand, ObjectModel=true)]
    protected override void OnLoad(EventArgs e)
    {
        this.EnsureChildControls();
        base.OnLoad(e);
        if ((((base.ControlMode == SPControlMode.Edit) &amp;amp;&amp;amp; (base.ListItem != null)) &amp;amp;&amp;amp; this.Page.IsPostBack) &amp;amp;&amp;amp; !base.InDesign)
        {
            HtmlInputHidden hidden = (HtmlInputHidden) this.TemplateContainer.FindControl(&amp;quot;owshiddenversion&amp;quot;);
            if (hidden == null)
            {
                throw new ArgumentException(&amp;quot;Corrupted ItemHiddenVersion template.&amp;quot;);
            }
            base.ListItem[&amp;quot;owshiddenversion&amp;quot;] = hidden.Value;
            Convert.ToInt32(hidden.Value, CultureInfo.InvariantCulture);
        }
    }&lt;/pre&gt;
&lt;p&gt;I guess the hidden.Value or owshiddenversion is empty or some sort of string.&amp;nbsp; Now Microsoft actually has an article on this owshiddenversion property [4] where they state:&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Windows SharePoint Services 3.0 uses the owshiddenversion Field (in the Microsoft.SharePoint.SPBuiltInFieldId Class) to detect conflicts. If this field value is not supplied during the update process, the server will overwrite all changes. A client must always supply this field value during the update process, in order to prevent data loss. The field value is the number that the server returned most recently.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;I guess what might be happening is that the page is in some sort of conflict state.&amp;nbsp; I&amp;rsquo;m going to try and remove the ItemHiddenVersion SharePoint control that was put in from the hotfix [2] to see what happens next.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="color:#ff0000;"&gt;***Update***&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I removed it (line below) and things &lt;strong&gt;&lt;em&gt;seem&lt;/em&gt;&lt;/strong&gt; to be working, let&amp;#39;s wait and see.&lt;/p&gt;
&lt;p&gt;&amp;lt;SharePoint:ItemHiddenVersion runat=&amp;quot;server&amp;quot; ControlMode=&amp;quot;Edit&amp;quot;/&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;[1] &lt;a href="http://kalsing.blogspot.com/2006/11/create-custom-list-form-for-sharepoint.html" title="http://kalsing.blogspot.com/2006/11/create-custom-list-form-for-sharepoint.html"&gt;http://kalsing.blogspot.com/2006/11/create-custom-list-form-for-sharepoint.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;[2] &lt;a href="http://support.microsoft.com/default.aspx/kb/953271" title="http://support.microsoft.com/default.aspx/kb/953271"&gt;http://support.microsoft.com/default.aspx/kb/953271&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;[3] &lt;a href="http://social.msdn.microsoft.com/forums/en-US/sharepointdevelopment/thread/ed33bbd4-a396-476e-b04e-88161dfbdac6/" title="http://social.msdn.microsoft.com/forums/en-US/sharepointdevelopment/thread/ed33bbd4-a396-476e-b04e-88161dfbdac6/"&gt;http://social.msdn.microsoft.com/forums/en-US/sharepointdevelopment/thread/ed33bbd4-a396-476e-b04e-88161dfbdac6/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;[4] &lt;a href="http://msdn.microsoft.com/en-us/library/cc264293.aspx" title="http://msdn.microsoft.com/en-us/library/cc264293.aspx"&gt;http://msdn.microsoft.com/en-us/library/cc264293.aspx&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.imason.com/aggbug.aspx?PostID=1252" width="1" height="1"&gt;</description><category domain="http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/tags/SharePoint+Designer/default.aspx">SharePoint Designer</category><category domain="http://www.imason.com/imason_Blogs/b/noorez_khamis/archive/tags/technical+technical/default.aspx">technical technical</category></item></channel></rss>