Hello,
i try to create a (point)-feature in an existing Layer via ArcGIS Automation.
I can create the Feature but when I call feature.Store() I get an "HRESULT: 0x80010105 (RPC_E_SERVERFAULT)" error.
If I just edit an existing feature that I got from a SearchCursor it works flawlessly.
My application is a WinForms .Net 4.5 programm.
I get a connection to a running ArcMap Instance via IAppRot->IAppRef->IApplication->IDocument.
From the IDocument I get a reference to a specific Layer where I need to add a feature.
After that it is very basic stuff:
IFeatureClass featureClass <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN>IFeatureLayer<SPAN class="punctuation token">)</SPAN>i_Layer<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>FeatureClass<SPAN class="punctuation token">;</SPAN>
IFeature newObject <SPAN class="operator token">=</SPAN> featureClass<SPAN class="punctuation token">.</SPAN><SPAN class="token function">CreateFeature</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Assign a geometry to the feature </SPAN>
newObject<SPAN class="punctuation token">.</SPAN>Shape <SPAN class="operator token">=</SPAN> geom<SPAN class="punctuation token">;</SPAN>
newObject<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Store</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>
Store allways fails with the RPC_E_SERVERFAULT Exception.
I also tried to create the feature via IFeatureCursor->IFeatureBuffer but then it fails with the same error on
featureCursor<SPAN class="punctuation token">.</SPAN><SPAN class="token function">InsertFeature</SPAN><SPAN class="punctuation token">(</SPAN>featureBuffer<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
Starting an Edit-Session for this operation has no effect. It just fails later when calling
workspaceEdit<SPAN class="punctuation token">.</SPAN><SPAN class="token function">StopEditing</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
I tried with ArcGIS 10.5 an 10.3 but the results are the same.
Other automation tasks like moving the map, setting layer-visibilities or even editing existing features work perfectly.
I read the introduction on ArcGIS automation in the documentation and learned about application's process space and "IObjectFactory".
Do I have to use that somehow to create the new Feature? How can I do that?
Or is there something else that I am doing wrong?
Any idea is apreciated!!
Thanks,
Stefan