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

<channel>
	<title>Nebulae Spiral &#187; sharepoint</title>
	<atom:link href="http://inmyshadow.net/tag/sharepoint/feed/" rel="self" type="application/rss+xml" />
	<link>http://inmyshadow.net</link>
	<description>Spiralling Golden... and maybe blogging about code.</description>
	<lastBuildDate>Tue, 23 Dec 2008 04:17:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>RPC_E_ATTEMPTED_MULTITHREAD</title>
		<link>http://inmyshadow.net/2008/09/04/rpc_e_attempted_multithread/</link>
		<comments>http://inmyshadow.net/2008/09/04/rpc_e_attempted_multithread/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 16:02:22 +0000</pubDate>
		<dc:creator>Nebulae</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[exceptions]]></category>
		<category><![CDATA[moss]]></category>
		<category><![CDATA[sharepoint]]></category>

		<guid isPermaLink="false">http://inmyshadow.net/?p=143</guid>
		<description><![CDATA[Exception information:
Exception type: COMException
Exception message: Attempted to make calls on more than one thread in single threaded mode. (Exception from HRESULT: 0&#215;80010102 (RPC_E_ATTEMPTED_MULTITHREAD))
ooh yah baby.  this ones a doozy.
If you&#8217;re running into this in your sharepoint development journey, you have well bypassed the open site / open list / get list item / do [...]]]></description>
			<content:encoded><![CDATA[<p>Exception information:<br />
Exception type: COMException<br />
Exception message: Attempted to make calls on more than one thread in single threaded mode. (Exception from HRESULT: 0&#215;80010102 (RPC_E_ATTEMPTED_MULTITHREAD))</p>
<p>ooh yah baby.  this ones a doozy.</p>
<p>If you&#8217;re running into this in your sharepoint development journey, you have well bypassed the open site / open list / get list item / do stuff with it stage and have moved into the world of creating object representations of your list items, probably databinding that object off the list item to work with it, then populating the listitem columns from the object before saving it.  IMHO, this is a nice, clean and managable way of development, BUT you could run into a couple roadblocks.  this one looks a tad daunting but its an easy one to get around.</p>
<p>My scenario uses 3 lists.  Registrations, Organizations, and Solutions.  An Organization has an owner (registration) and 0-many solutions.  I know, I know, the organization should be a property of the registration, but i digress&#8230;</p>
<p>so i have an organization object.  this object has a bunch of fancy properties &#8211; address, phone number, etc, etc, and also an Owner and a List&lt;Solution&gt; .  During the databind of this object from the listitem, I attempted to set these objects and received the RPC_E_ATTEMPTED_MULTITHREAD error &#8211; if you google this error, which you probably have since you landed here, you&#8217;ll see some answers that will have you believe that you need to implicitly dispose of the SPSite, SPWeb &#8211; you may even be tempted to add a GC.Collect in there.</p>
<p>This didn&#8217;t &#8211; and still doesn&#8217;t &#8211; make a whole lot of sense to me because the access to the list item was wrapped in a using statement which of course only works with types that inherit from IDisposable, and will be disposed of when you exit the using statement, right?  Right? so you would think that after you access that list item and leave the using statement, the SPSite is disposed of and youre good to go&#8230; which is not really the case and I don&#8217;t know the intricacies of it all but I do know how to bypass this problem and the answer is &#8211; Lazy Loading.  yes, serious.</p>
<p>back to my databind&#8230;<br />
as I am binding all the properties from the listitem i just retrieved and I try to set the owner which would have to go access that site and get that list item from the registrations list, create a new owner object from that item, the RPC_E_ATTEMPTED_MULTITHREAD error gets thrown.  the same when I&#8217;m trying to populate the Associated Solutions.  If you move the code to populate these properties into the public accessor ( the getter ) so that the property is loaded when it is accessed instead of when the object is databound &#8211; poof!  problem solved.</p>
<p>If this doesn&#8217;t solve your problem, or you&#8217;re seeing this error in Sharepoint without having the structure i described above or some format of it, drop me a line and we can figure it out.</p>
<p>cheers,<br />
trinity<br />
err, neb</p>
]]></content:encoded>
			<wfw:commentRss>http://inmyshadow.net/2008/09/04/rpc_e_attempted_multithread/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Handy SPFolder / SPList / SPFile / SPWhatever interface, using Generics and Elevated Privs.</title>
		<link>http://inmyshadow.net/2008/08/28/handy-spfolder-splist-spfile-spwhatever-interface-using-generics/</link>
		<comments>http://inmyshadow.net/2008/08/28/handy-spfolder-splist-spfile-spwhatever-interface-using-generics/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 17:01:43 +0000</pubDate>
		<dc:creator>Nebulae</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[moss]]></category>
		<category><![CDATA[sharepoint]]></category>

		<guid isPermaLink="false">http://inmyshadow.net/?p=132</guid>
		<description><![CDATA[This is a handly little lib I wrote for accessing various types of objects using generics.  enjoy :-)

class SPDataAdapter
&#123;
    public static T GetObject&#40;string location&#41;
    &#123;
        object obj = null;
        SPSecurity.RunWithElevatedPrivileges&#40;delegate
     [...]]]></description>
			<content:encoded><![CDATA[<p>This is a handly little lib I wrote for accessing various types of objects using generics.  enjoy :-)</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #FF0000;">class</span> SPDataAdapter
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> T GetObject<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> location<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #FF0000;">object</span> obj <span style="color: #008000;">=</span> null<span style="color: #008000;">;</span>
        SPSecurity.<span style="color: #0000FF;">RunWithElevatedPrivileges</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">delegate</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">using</span> <span style="color: #000000;">&#40;</span>var site <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> SPSite<span style="color: #000000;">&#40;</span>location<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                obj <span style="color: #008000;">=</span> site.<span style="color: #0000FF;">OpenWeb</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">GetObject</span><span style="color: #000000;">&#40;</span>location<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">return</span> <span style="color: #000000;">&#40;</span>T<span style="color: #000000;">&#41;</span>obj<span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> T GetObject<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> location, <span style="color: #FF0000;">bool</span> useElevatedPrivs<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>useElevatedPrivs<span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">return</span> GetObject<span style="color: #000000;">&#40;</span>location<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">using</span> <span style="color: #000000;">&#40;</span>var site <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> SPSite<span style="color: #000000;">&#40;</span>location<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">return</span> <span style="color: #000000;">&#40;</span>T<span style="color: #000000;">&#41;</span>site.<span style="color: #0000FF;">OpenWeb</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">GetObject</span><span style="color: #000000;">&#40;</span>location<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> SPList GetList<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> location, <span style="color: #FF0000;">bool</span> useElevatedPrivs<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>useElevatedPrivs<span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">return</span> GetList<span style="color: #000000;">&#40;</span>location<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">using</span> <span style="color: #000000;">&#40;</span>var site <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> SPSite<span style="color: #000000;">&#40;</span>location<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">return</span> site.<span style="color: #0000FF;">OpenWeb</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">GetList</span><span style="color: #000000;">&#40;</span>location<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> SPList GetList<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> location<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        SPList list <span style="color: #008000;">=</span> null<span style="color: #008000;">;</span>
        SPSecurity.<span style="color: #0000FF;">RunWithElevatedPrivileges</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">delegate</span>
       <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">using</span> <span style="color: #000000;">&#40;</span>var site <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> SPSite<span style="color: #000000;">&#40;</span>location<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                list <span style="color: #008000;">=</span> site.<span style="color: #0000FF;">OpenWeb</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">GetList</span><span style="color: #000000;">&#40;</span>location<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF;">return</span> list<span style="color: #008000;">;</span>
&nbsp;
   <span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>and to test:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">&nbsp;
<span style="color: #000000;">&#91;</span>TestMethod<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> GetObjectTest1<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    GetObjectTest1Helper<span style="color: #008000;">&lt;</span>SPFolder<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> GetObjectTest1Helper<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">const</span> <span style="color: #FF0000;">string</span> location <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;http://spiral/Lists/Tasks&quot;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF;">const</span> <span style="color: #FF0000;">bool</span> useElevatedPrivs <span style="color: #008000;">=</span> true<span style="color: #008000;">;</span>
    var actual <span style="color: #008000;">=</span> SPDataAdapter.<span style="color: #0000FF;">GetObject</span><span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span>location, useElevatedPrivs<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    Assert.<span style="color: #0000FF;">IsNotNull</span><span style="color: #000000;">&#40;</span>actual<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #000000;">&#91;</span>TestMethod<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> GetObjectTest<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    GetObjectTestHelper<span style="color: #008000;">&lt;</span>SPFile<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> GetObjectTestHelper<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">const</span> <span style="color: #FF0000;">string</span> location <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;http://spiral/Lists/Tasks/Attachments/1/nebulae.jpg&quot;</span><span style="color: #008000;">;</span>
    T actual <span style="color: #008000;">=</span> SPDataAdapter.<span style="color: #0000FF;">GetObject</span><span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span>location<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    Assert.<span style="color: #0000FF;">IsNotNull</span><span style="color: #000000;">&#40;</span>actual<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://inmyshadow.net/2008/08/28/handy-spfolder-splist-spfile-spwhatever-interface-using-generics/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SPList Factory &#8211; singleton access to your lists.</title>
		<link>http://inmyshadow.net/2008/08/06/splist-factory-singleton-access-to-your-lists/</link>
		<comments>http://inmyshadow.net/2008/08/06/splist-factory-singleton-access-to-your-lists/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 19:17:11 +0000</pubDate>
		<dc:creator>Nebulae</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[design patterns]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[moss]]></category>
		<category><![CDATA[sharepoint]]></category>

		<guid isPermaLink="false">http://inmyshadow.net/?p=108</guid>
		<description><![CDATA[A few months ago I was doing a refresher in GOF design patterns.  I have a couple favorites: memento, observer, state, and the factory of course :-)
So I was trying to implement these patterns in a conceptual SPAL ( sp access layer ), and what I&#8217;ve found is that having a SPListWrapper object, and a [...]]]></description>
			<content:encoded><![CDATA[<p>A few months ago I was doing a refresher in GOF design patterns.  I have a couple favorites: memento, observer, state, and the factory of course :-)</p>
<p>So I was trying to implement these patterns in a conceptual SPAL ( sp access layer ), and what I&#8217;ve found is that having a SPListWrapper object, and a factory to create them and allow static access is *<a title="please see the bees knees " href="http://farm1.static.flickr.com/31/60685364_cb0d3602ec.jpg" target="_blank">the bees knees</a>*, especially if you want to implement an ajax interface.  Since you only load the list once, its pretty speedy too.</p>
<p>I absolutely love ajax and making the sharepoint interface more robust and seamless.  Any interface for that matter.  there is a library i use exclusively that covers all browsers and addresses the issues found in each of them, even the pesky ie memory leak.</p>
<p>What Im getting at is that I have a bunch of cool stuff to share that probably would become convoluted in a mass array of blog entries, so I think it would be worthwhile to vlog it.  stay tuned, could take a  <span style="text-decoration: line-through;">few days</span> while.</p>
]]></content:encoded>
			<wfw:commentRss>http://inmyshadow.net/2008/08/06/splist-factory-singleton-access-to-your-lists/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Save Conflict in workflow on SPListItem.Update or SystemUpdate</title>
		<link>http://inmyshadow.net/2008/08/01/save-conflict-in-workflow-on-splistitemupdate-or-systemupdate/</link>
		<comments>http://inmyshadow.net/2008/08/01/save-conflict-in-workflow-on-splistitemupdate-or-systemupdate/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 08:16:18 +0000</pubDate>
		<dc:creator>Nebulae</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[moss]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[worklow]]></category>

		<guid isPermaLink="false">http://inmyshadow.net/?p=72</guid>
		<description><![CDATA[in this scenario, I have a really simple workflow that creates a task, does some infopath approval stuff, then copies that list item to another list.  the kicker is when you want to add something about that copied item to the original item, say an id column so you have a reference.  after [...]]]></description>
			<content:encoded><![CDATA[<p>in this scenario, I have a really simple workflow that creates a task, does some infopath approval stuff, then copies that list item to another list.  the kicker is when you want to add something about that copied item to the original item, say an id column so you have a reference.  after saving the copy, you set a column on the original and try to update the listitem, and get a &#8220;save conflict&#8221; error.  </p>
<p>Ive seen a lot of posts on this error, most of them point to not having access to that listitem because its locked by the workflow itself.  I would assume that you can somehow capture the item before the workflow updates it, and set the properties you want.  could someone enlighten me if this is true?  I&#8217;ve seen posts saying to use a delay, to wrap it in a repeating try / catch until the item is unlocked, to try programmatically to check it out, and then save it.  I can&#8217;t see any of this as being best answer.  </p>
<p>What Ive decided is to attach an event handler to the second list to set the id in the first.  this seems to be pretty reliable, plus I already had an event handler on that list.  I&#8217;m really curious to know if there&#8217;s a resolution for this.  </p>
<p>other info on this issue:<br />
<a href="http://forums.msdn.microsoft.com/en-US/sharepointdevelopment/thread/641b40fb-614f-4266-95c0-d61c2f443146/">http://forums.msdn.microsoft.com/en-US/sharepointdevelopment/thread/641b40fb-614f-4266-95c0-d61c2f443146/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://inmyshadow.net/2008/08/01/save-conflict-in-workflow-on-splistitemupdate-or-systemupdate/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sharepoint Workflow &#8211; When you just can&#8217;t create a task.</title>
		<link>http://inmyshadow.net/2008/07/27/sharepoint-workflow-when-you-just-cant-create-a-task/</link>
		<comments>http://inmyshadow.net/2008/07/27/sharepoint-workflow-when-you-just-cant-create-a-task/#comments</comments>
		<pubDate>Sun, 27 Jul 2008 20:41:56 +0000</pubDate>
		<dc:creator>Nebulae</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[moss]]></category>
		<category><![CDATA[sharepoint]]></category>

		<guid isPermaLink="false">http://inmyshadow.net/?p=21</guid>
		<description><![CDATA[I&#8217;ve been writing sharepoint applications for quite some time.  In fact, I consider myself pretty damn good at it.  Somehow though, I&#8217;ve been able to avoid writing much workflow all this time.  Event Handlers have been all I needed to this point.
I&#8217;ve never wanted to beat my head into a wall so much as this [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been writing sharepoint applications for quite some time.  In fact, I consider myself pretty damn good at it.  Somehow though, I&#8217;ve been able to avoid writing much workflow all this time.  Event Handlers have been all I needed to this point.</p>
<p>I&#8217;ve never wanted to beat my head into a wall so much as this last weeks adventure into workflow.  The infamous Julie kremer, who i hold in the highest of esteem as a friend and teacher, wrote a workflow for the OfficeLive app that Ive been working on for the last 5 or so months ( I think we&#8217;re on version 5 at this point, we iterate fast ) that takes a solution submitted by a small business owner and kicks off a workflow to have it approved before it shows up in the small business portal search &#8211; <a title="http://www.officelivepartnerdirectory.com" href="http://www.officelivepartnerdirectory.com/US/Pages/default.aspx" target="_blank">http://www.officelivepartnerdirectory.com</a>.</p>
<p>My task is to create a workflow that the company object will pass through for approval.  The goal is to catch any offensive company names or logos from showing up in the portal.  This seems pretty easy, logistical, shouldn&#8217;t be a problem right?</p>
<p>Well, right off the bat I was getting an exception in mscorlib</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">Exception has been thrown by the target of an invocation.
   <span style="color: #0000FF;">at</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">RuntimeMethodHandle</span>._InvokeMethodFast<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">Object</span> target, <span style="color: #FF0000;">Object</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> arguments, SignatureStruct<span style="color: #008000;">&amp;</span>amp<span style="color: #008000;">;</span> sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner<span style="color: #000000;">&#41;</span>
   at <span style="color: #000000;">System</span>.<span style="color: #0000FF;">RuntimeMethodHandle</span>.<span style="color: #0000FF;">InvokeMethodFast</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">Object</span> target, <span style="color: #FF0000;">Object</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner<span style="color: #000000;">&#41;</span>
   at <span style="color: #000000;">System.<span style="color: #0000FF;">Reflection</span></span>.<span style="color: #0000FF;">RuntimeMethodInfo</span>.<span style="color: #0000FF;">Invoke</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">Object</span> obj, BindingFlags invokeAttr, Binder binder, <span style="color: #FF0000;">Object</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> parameters, CultureInfo culture, Boolean skipVisibilityChecks<span style="color: #000000;">&#41;</span>
   at <span style="color: #000000;">System.<span style="color: #0000FF;">Reflection</span></span>.<span style="color: #0000FF;">RuntimeMethodInfo</span>.<span style="color: #0000FF;">Invoke</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">Object</span> obj, BindingFlags invokeAttr, Binder binder, <span style="color: #FF0000;">Object</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> parameters, CultureInfo culture<span style="color: #000000;">&#41;</span>
   at <span style="color: #000000;">System</span>.<span style="color: #0000FF;">RuntimeType</span>.<span style="color: #0000FF;">InvokeMember</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">String</span> name, BindingFlags bindingFlags, Binder binder, <span style="color: #FF0000;">Object</span> target, <span style="color: #FF0000;">Object</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> providedArgs, ParameterModifier<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> modifiers, CultureInfo culture, <span style="color: #FF0000;">String</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> namedParams<span style="color: #000000;">&#41;</span>
   at <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Workflow</span>.<span style="color: #0000FF;">Activities</span>.<span style="color: #0000FF;">CallExternalMethodActivity</span>.<span style="color: #0000FF;">Execute</span><span style="color: #000000;">&#40;</span>ActivityExecutionContext executionContext<span style="color: #000000;">&#41;</span>
   at <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Workflow</span>.<span style="color: #0000FF;">ComponentModel</span>.<span style="color: #0000FF;">ActivityExecutor</span>`1.<span style="color: #0000FF;">Execute</span><span style="color: #000000;">&#40;</span>T activity, ActivityExecutionContext executionContext<span style="color: #000000;">&#41;</span>
   at <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Workflow</span>.<span style="color: #0000FF;">ComponentModel</span>.<span style="color: #0000FF;">ActivityExecutor</span>`1.<span style="color: #0000FF;">Execute</span><span style="color: #000000;">&#40;</span>Activity activity, ActivityExecutionContext executionContext<span style="color: #000000;">&#41;</span>
   at <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Workflow</span>.<span style="color: #0000FF;">ComponentModel</span>.<span style="color: #0000FF;">ActivityExecutorOperation</span>.<span style="color: #0000FF;">Run</span><span style="color: #000000;">&#40;</span>IWorkflowCoreRuntime workflowCoreRuntime<span style="color: #000000;">&#41;</span>
   at <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Workflow</span>.<span style="color: #0000FF;">Runtime</span>.<span style="color: #0000FF;">Scheduler</span>.<span style="color: #0000FF;">Run</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></pre></div></div>

<p>I added a fault handler to the workflow and bubbled up the inner exception to see what the deal was:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">private</span> <span style="color: #0600FF;">void</span> code_HandleAllExceptions_ExecuteCode<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, EventArgs e<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    WriteException<span style="color: #000000;">&#40;</span>faultHandlerActivity1_Fault1, <span style="color: #666666;">&quot;An error was handled by fault hander. &quot;</span> <span style="color: #008000;">+</span> faultHandlerActivity1_Fault1.<span style="color: #0000FF;">InnerException</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0600FF;">private</span> <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> WriteException<span style="color: #000000;">&#40;</span>Exception e, <span style="color: #FF0000;">string</span> message<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    WriteTrace<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;CompanyWF ERROR: &quot;</span> <span style="color: #008000;">+</span> message <span style="color: #008000;">+</span> <span style="color: #666666;">&quot; &quot;</span> <span style="color: #008000;">+</span> e.<span style="color: #0000FF;">Message</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\n</span>&quot;</span> <span style="color: #008000;">+</span> e.<span style="color: #0000FF;">StackTrace</span>, <span style="color: #666666;">&quot;ERROR&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0600FF;">private</span> <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> WriteInfo<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> message<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    WriteTrace<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;CompanyWF: &quot;</span> <span style="color: #008000;">+</span> message, <span style="color: #666666;">&quot;INFO&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0600FF;">private</span> <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> WriteTrace<span style="color: #000000;">&#40;</span> <span style="color: #FF0000;">string</span> message, <span style="color: #FF0000;">string</span> level <span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    Trace.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;[&quot;</span><span style="color: #008000;">+</span>DateTime.<span style="color: #0000FF;">Now</span><span style="color: #008000;">+</span><span style="color: #666666;">&quot;] &quot;</span> <span style="color: #008000;">+</span> message, level<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>which then reported a null reference exception:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #000000;">&#91;</span><span style="color: #FF0000;">4120</span><span style="color: #000000;">&#93;</span> ERROR<span style="color: #008000;">:</span> <span style="color: #000000;">&#91;</span><span style="color: #FF0000;">7</span><span style="color: #008000;">/</span><span style="color: #FF0000;">25</span><span style="color: #008000;">/</span><span style="color: #FF0000;">2008</span> <span style="color: #FF0000;">10</span><span style="color: #008000;">:</span><span style="color: #FF0000;">36</span><span style="color: #008000;">:</span><span style="color: #FF0000;">46</span> AM<span style="color: #000000;">&#93;</span> CompanyWF ERROR<span style="color: #008000;">:</span> An error was handled by fault hander. <span style="color: #000000;">System</span>.<span style="color: #0000FF;">NullReferenceException</span><span style="color: #008000;">:</span> <span style="color: #FF0000;">Object</span> reference not set to an instance of an <span style="color: #FF0000;">object</span>.
<span style="color: #000000;">&#91;</span><span style="color: #FF0000;">4120</span><span style="color: #000000;">&#93;</span>    at Microsoft.<span style="color: #0000FF;">SharePoint</span>.<span style="color: #0000FF;">Workflow</span>.<span style="color: #0000FF;">SPWorkflowTask</span>.<span style="color: #0000FF;">SetWorkflowData</span><span style="color: #000000;">&#40;</span>SPListItem task, Hashtable newValues, Boolean ignoreReadOnly<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#91;</span><span style="color: #FF0000;">4120</span><span style="color: #000000;">&#93;</span>    at Microsoft.<span style="color: #0000FF;">SharePoint</span>.<span style="color: #0000FF;">Workflow</span>.<span style="color: #0000FF;">SPWinOETaskService</span>.<span style="color: #0000FF;">UpdateTaskInternal</span><span style="color: #000000;">&#40;</span>Guid taskId, SPWorkflowTaskProperties properties, Boolean fSetWorkflowFinalize, Boolean fCreating, HybridDictionary specialPermissions<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#91;</span><span style="color: #FF0000;">4120</span><span style="color: #000000;">&#93;</span>    at Microsoft.<span style="color: #0000FF;">SharePoint</span>.<span style="color: #0000FF;">Workflow</span>.<span style="color: #0000FF;">SPWinOETaskService</span>.<span style="color: #0000FF;">CreateTaskWithContentTypeInternal</span><span style="color: #000000;">&#40;</span>Guid taskId, SPWorkflowTaskProperties properties, Boolean useDefaultContentType, SPContentTypeId ctid, HybridDictionary specialPermissions<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#91;</span><span style="color: #FF0000;">4120</span><span style="color: #000000;">&#93;</span>    at Microsoft.<span style="color: #0000FF;">SharePoint</span>.<span style="color: #0000FF;">Workflow</span>.<span style="color: #0000FF;">SPWinOETaskService</span>.<span style="color: #0000FF;">CreateTask</span><span style="color: #000000;">&#40;</span>Guid taskId, SPWorkflowTaskProperties properties, HybridDictionary specialPermissions<span style="color: #000000;">&#41;</span> Exception has been thrown by the target of an invocation.
<span style="color: #000000;">&#91;</span><span style="color: #FF0000;">4120</span><span style="color: #000000;">&#93;</span>    at <span style="color: #000000;">System</span>.<span style="color: #0000FF;">RuntimeMethodHandle</span>._InvokeMethodFast<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">Object</span> target, <span style="color: #FF0000;">Object</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> arguments, SignatureStruct<span style="color: #008000;">&amp;</span>amp<span style="color: #008000;">;</span> sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#91;</span><span style="color: #FF0000;">4120</span><span style="color: #000000;">&#93;</span>    at <span style="color: #000000;">System</span>.<span style="color: #0000FF;">RuntimeMethodHandle</span>.<span style="color: #0000FF;">InvokeMethodFast</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">Object</span> target, <span style="color: #FF0000;">Object</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#91;</span><span style="color: #FF0000;">4120</span><span style="color: #000000;">&#93;</span>    at <span style="color: #000000;">System.<span style="color: #0000FF;">Reflection</span></span>.<span style="color: #0000FF;">RuntimeMethodInfo</span>.<span style="color: #0000FF;">Invoke</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">Object</span> obj, BindingFlags invokeAttr, Binder binder, <span style="color: #FF0000;">Object</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> parameters, CultureInfo culture, Boolean skipVisibilityChecks<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#91;</span><span style="color: #FF0000;">4120</span><span style="color: #000000;">&#93;</span>    at <span style="color: #000000;">System.<span style="color: #0000FF;">Reflection</span></span>.<span style="color: #0000FF;">RuntimeMethodInfo</span>.<span style="color: #0000FF;">Invoke</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">Object</span> obj, BindingFlags invokeAttr, Binder binder, <span style="color: #FF0000;">Object</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> parameters, CultureInfo culture<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#91;</span><span style="color: #FF0000;">4120</span><span style="color: #000000;">&#93;</span>    at <span style="color: #000000;">System</span>.<span style="color: #0000FF;">RuntimeType</span>.<span style="color: #0000FF;">InvokeMember</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">String</span> name, BindingFlags bindingFlags, Binder binder, <span style="color: #FF0000;">Object</span> target, <span style="color: #FF0000;">Object</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> providedArgs, ParameterModifier<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> modifiers, CultureInfo culture, <span style="color: #FF0000;">String</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> namedParams<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#91;</span><span style="color: #FF0000;">4120</span><span style="color: #000000;">&#93;</span>    at <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Workflow</span>.<span style="color: #0000FF;">Activities</span>.<span style="color: #0000FF;">CallExternalMethodActivity</span>.<span style="color: #0000FF;">Execute</span><span style="color: #000000;">&#40;</span>ActivityExecutionContext executionContext<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#91;</span><span style="color: #FF0000;">4120</span><span style="color: #000000;">&#93;</span>    at <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Workflow</span>.<span style="color: #0000FF;">ComponentModel</span>.<span style="color: #0000FF;">ActivityExecutor</span>`1.<span style="color: #0000FF;">Execute</span><span style="color: #000000;">&#40;</span>T activity, ActivityExecutionContext executionContext<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#91;</span><span style="color: #FF0000;">4120</span><span style="color: #000000;">&#93;</span>    at <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Workflow</span>.<span style="color: #0000FF;">ComponentModel</span>.<span style="color: #0000FF;">ActivityExecutor</span>`1.<span style="color: #0000FF;">Execute</span><span style="color: #000000;">&#40;</span>Activity activity, ActivityExecutionContext executionContext<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#91;</span><span style="color: #FF0000;">4120</span><span style="color: #000000;">&#93;</span>    at <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Workflow</span>.<span style="color: #0000FF;">ComponentModel</span>.<span style="color: #0000FF;">ActivityExecutorOperation</span>.<span style="color: #0000FF;">Run</span><span style="color: #000000;">&#40;</span>IWorkflowCoreRuntime workflowCoreRuntime<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#91;</span><span style="color: #FF0000;">4120</span><span style="color: #000000;">&#93;</span>    at <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Workflow</span>.<span style="color: #0000FF;">Runtime</span>.<span style="color: #0000FF;">Scheduler</span>.<span style="color: #0000FF;">Run</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></pre></div></div>

<p>One of the properties I was trying to push into the ExtendedProperties propertybag was null, I changed that and we were past this exception.  The lesson here is to grab the InnerException of your fault handler and hope that it returns something descriptive, i guess :-)</p>
<p>In case you are wondering, the trace viewer i use is called DebugView, brought to my attention by the industrious Eric Jobin.</p>
<p>Another issue I was having with the InfoPath form though, was quite a bit harder to track down, but a stupid mistake in the long run.  I was creating a link to the infopath form with an item id in the query string, but it was the wrong item, wrong list :-)  The error I was getting was something extremely vague and Sharepointy, but what helped me figure it out was enabling (in a google friendly fashion) &#8211; verbose sharepoint  exception reporting &#8211; verbose sharepoint error handling &#8211; full Moss exception handling &#8211; good enough.</p>
<p>This is a lot easier than you might think, and you&#8217;ve probably done this before with other web applications you&#8217;ve needed to debug.  Open the Web.Config for your spsite and find:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SharePoint<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SafeMode</span> <span style="color: #000066;">MaxControls</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #000066;">CallStack</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000066;">DirectFileDependencies</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000066;">TotalFileDependencies</span>=<span style="color: #ff0000;">&quot;50&quot;</span> <span style="color: #000066;">AllowPageLevelTrace</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></div></div>

<p>and change it to:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SharePoint<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SafeMode</span> <span style="color: #000066;">MaxControls</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #000066;">CallStack</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">DirectFileDependencies</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000066;">TotalFileDependencies</span>=<span style="color: #ff0000;">&quot;50&quot;</span> <span style="color: #000066;">AllowPageLevelTrace</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></div></div>

<p>then find the node:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;system.web<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;customErrors</span> <span style="color: #000066;">mode</span>=<span style="color: #ff0000;">&quot;On&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>and set it to &#8220;Off&#8221;</p>
<p>you may have to recycle your app pool before changes take effect, but you should now see a stack trace when you cause an error &#8211; hopefully more helpful than the generic Unknown Exception that we had all come to love.  </p>
<p>peace, and happy coding&#8230;<br />
trinity</p>
]]></content:encoded>
			<wfw:commentRss>http://inmyshadow.net/2008/07/27/sharepoint-workflow-when-you-just-cant-create-a-task/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chris O&#8217;Brien&#8217;s blog</title>
		<link>http://inmyshadow.net/2008/07/27/chris-obriens-blog/</link>
		<comments>http://inmyshadow.net/2008/07/27/chris-obriens-blog/#comments</comments>
		<pubDate>Sun, 27 Jul 2008 17:38:44 +0000</pubDate>
		<dc:creator>Nebulae</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[moss]]></category>
		<category><![CDATA[sharepoint]]></category>

		<guid isPermaLink="false">http://inmyshadow.net/?p=31</guid>
		<description><![CDATA[Chris O&#8217;Brien&#8217;s blog. &#8211; Great SharePoint resource.
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sharepointnutsandbolts.com/">Chris O&#8217;Brien&#8217;s blog</a>. &#8211; Great SharePoint resource.</p>
]]></content:encoded>
			<wfw:commentRss>http://inmyshadow.net/2008/07/27/chris-obriens-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
