I have no idea what why i can't figure this out, but after hours of trying i am finally having to get some help. All I want to do is get the selected line feature from a FeatureLayer object so I can get the starting point (fromPoint). Here is my current version of code:
QueuedTask<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Run</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">var</SPAN> gsSelection <SPAN class="operator token">=</SPAN> gsFLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetSelection</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">using</SPAN> <SPAN class="punctuation token">(</SPAN>ArcGIS<SPAN class="punctuation token">.</SPAN>Core<SPAN class="punctuation token">.</SPAN>Data<SPAN class="punctuation token">.</SPAN>RowCursor rCursor <SPAN class="operator token">=</SPAN> gsSelection<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Search</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">while</SPAN> <SPAN class="punctuation token">(</SPAN>rCursor<SPAN class="punctuation token">.</SPAN><SPAN class="token function">MoveNext</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
Feature gsFeature <SPAN class="operator token">=</SPAN> rCursor<SPAN class="punctuation token">.</SPAN>Current <SPAN class="keyword token">as</SPAN> Feature<SPAN class="punctuation token">;</SPAN>
IPolyline6 gsPolyline <SPAN class="operator token">=</SPAN> gsFeature <SPAN class="keyword token">as</SPAN> IPolyline6<SPAN class="punctuation token">;</SPAN>
IPoint fromPoint <SPAN class="operator token">=</SPAN> gsPolyline<SPAN class="punctuation token">.</SPAN>FromPoint<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="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>Earlier in my code I use this to get the layer, which appears to be working. I can get to the attributes of the selected feature without any issues.
gsFLayer <SPAN class="operator token">=</SPAN> map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetLayersAsFlattenedList</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>OfType<SPAN class="operator token"><</SPAN>ArcGIS<SPAN class="punctuation token">.</SPAN>Desktop<SPAN class="punctuation token">.</SPAN>Mapping<SPAN class="punctuation token">.</SPAN>FeatureLayer<SPAN class="operator token">></SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">Where</SPAN><SPAN class="punctuation token">(</SPAN>l <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN> l<SPAN class="punctuation token">.</SPAN>Name<SPAN class="punctuation token">.</SPAN><SPAN class="token function">IndexOf</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"GISWRKS1.WORKS.GravitySewer"</SPAN><SPAN class="punctuation token">,</SPAN> StringComparison<SPAN class="punctuation token">.</SPAN>CurrentCultureIgnoreCase<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">>=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">FirstOrDefault</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
I get a NullReference exception at IPoint fromPoint = gsPolyline.FromPoint;
Any help is appreciated.
Thanks!