Hi,
I'm using the following code to determine if a field exists in the current layer:
<SPAN class="keyword token">var</SPAN> currentLayer <SPAN class="operator token">=</SPAN> map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">FindLayers</SPAN><SPAN class="punctuation token">(</SPAN>layer<SPAN class="punctuation token">.</SPAN>Name<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="keyword token">as</SPAN> BasicFeatureLayer<SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//Does current layer have FACILITYID field??</SPAN>
Boolean facID_field <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">;</SPAN>
TableDefinition tableDef <SPAN class="operator token">=</SPAN> currentLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetTable</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetDefinition</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>tableDef<SPAN class="punctuation token">.</SPAN><SPAN class="token function">FindField</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"FACILITYID"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">>=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN>
facID_field <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">true</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>
When I do not have a Join setup on the layer everything is fine, but with a Join I will get an "InvalidOperationException" error on the TableDefinition line of code:
An exception of type 'System.InvalidOperationException' occurred in ArcGIS.Core.dll but was not handled in user code
Additional information: The dataset 'SAN_Manhole_MH_dbf' does not have a valid definition.
In this case, the layername is 'SAN_Manhole' and the joined table is 'MH_dbf'.
Is there another way I should be looking for fields in a layer?? Or is there just an issue with Joined layers going on in the background.
Thanks,