Hi,
So I've written an Editor Extension which has some code that runs when a feature is deleted. Everything works 100% as needed, but today I decided to add a few lines of code to track some information in a Share Point List when a feature gets deleted. As soon as I add that code, none of the code within my onDeleteFeature event fires. It's like it doesn't even exists. But....as soon as I comment out the code I added, everything works fine. Really weird. I don't know what the heck is going on.
See below. The code below works, but as soon as I uncomment the commented out section, nothing works. i don't even get the message box to pop up. If I debug, nothing in this entire code block runs, but the delete still happens in ArcMap.
Any ideas??
<SPAN class="comment token">//When a feature is Deleted.</SPAN>
<SPAN class="keyword token">void</SPAN> <SPAN class="token function">Events_OnDeleteFeature</SPAN><SPAN class="punctuation token">(</SPAN>ESRI<SPAN class="punctuation token">.</SPAN>ArcGIS<SPAN class="punctuation token">.</SPAN>Geodatabase<SPAN class="punctuation token">.</SPAN>IObject obj<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">try</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>obj <SPAN class="keyword token">is</SPAN> IFeature<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">//Cast to an IFeature</SPAN>
IFeature inFeature <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>IFeature<SPAN class="punctuation token">)</SPAN>obj<SPAN class="punctuation token">;</SPAN>
ITable inTable <SPAN class="operator token">=</SPAN> obj<SPAN class="punctuation token">.</SPAN>Table<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>inTable <SPAN class="keyword token">is</SPAN> IVersionedObject<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
IVersionedObject3 vObject <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>IVersionedObject3<SPAN class="punctuation token">)</SPAN>inTable<SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//Check if the Features Table is Versioned. If not, then exit.</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>vObject<SPAN class="punctuation token">.</SPAN>IsRegisteredAsVersioned<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">//Look for the Maximo field and edit.</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>inFeature<SPAN class="punctuation token">.</SPAN>Fields<SPAN class="punctuation token">.</SPAN><SPAN class="token function">FindField</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"MXCREATIONSTATE"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">!=</SPAN> <SPAN class="operator token">-</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
MessageBox<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Show</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"DELETE"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//using (SPSite spSite = new SPSite("https://...."))</SPAN>
<SPAN class="comment token">//{</SPAN>
<SPAN class="comment token">// using (SPWeb spWeb = spSite.OpenWeb())</SPAN>
<SPAN class="comment token">// {</SPAN>
<SPAN class="comment token">// spWeb.AllowUnsafeUpdates = true;</SPAN>
<SPAN class="comment token">// SPList list = spWeb.Lists["GIS_Deletes"];</SPAN>
<SPAN class="comment token">// //Add an item</SPAN>
<SPAN class="comment token">// SPListItem newItem = list.Items.Add();</SPAN>
<SPAN class="comment token">// newItem["MXASSETNUM"] = inFeature.Fields.FindField("MXASSETNUM").ToString();</SPAN>
<SPAN class="comment token">// newItem["MXSITEID"] = inFeature.Fields.FindField("MXSITEID").ToString();</SPAN>
<SPAN class="comment token">// newItem.Update();</SPAN>
<SPAN class="comment token">// spWeb.AllowUnsafeUpdates = false;</SPAN>
<SPAN class="comment token">// }</SPAN>
<SPAN class="comment token">//}</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">catch</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="token class-name">Exception</SPAN> ex<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
MessageBox<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Show</SPAN><SPAN class="punctuation token">(</SPAN>ex<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ToString</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Error in OnDeleteFeature procedure."</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>