I have a maptool where I just place a marker on a map. Nothing else, no other business logic.
The marker is placed fine, however - when you look at the debug the amount of exceptions thrown from ArcGIS.Dektop.Mapping.dll is concerning.
What is going on here, should this be happening?
Here is my simple code:
internal class FooTool : MapTool
{
private IDisposable _graphic = null;
public FooTool()
{
IsSketchTool = true;
SketchType = SketchGeometryType.Point;
SketchOutputMode = SketchOutputMode.Map;
}
protected override async Task<bool> OnSketchCompleteAsync(ArcGIS.Core.Geometry.Geometry geometry)
{
try
{
MapPoint mapPoint = (MapPoint)geometry;
await QueuedTask.Run(() =>
{
var mapView = MapView.Active;
//Show marker
if (_graphic != null)
{
_graphic.Dispose();
}
_graphic = mapView.AddOverlay(mapPoint, SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.BlueRGB, 14, SimpleMarkerStyle.Pushpin).MakeSymbolReference());
});
}
catch (ArgumentException ae)
{
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(ae.Message, "Tool error");
}
catch (Exception ex)
{
Log.Error(ex);
}
return true;
}
}
Hi,
I have copied your code and it works fine on ArcGIS Pro 3.0.3 and ArcGIS Pro SDK for .NET 3.0.0.36057
What Visual Studio are you using? I am on:
Microsoft Visual Studio Enterprise 2022 (64-bit) - Current
Version 17.4.3
I think problem is in project or solution configuration.
Where do you begin with this sort of stuff?! I did the migration process, but who knows if its done it 100% right. It would seem it hasn't ported cleanly. I really don't want to start remaking all over project again.
I have created new tool (with FooTool nam) in existing Esri community sample project (3.0), then copy/pasted your code inside existing FooTool class
No I don't mean that. I mean my actual project/add-in. Its huge from version 2.x of Pro. If I have to start a new addin project and copy in all the code and start again - thats a real pain in the backside!
I have solutions migrated from 2.x to 3.0, but I haven't issues like yours. Migration was painful to me too.
I have made all steps of migration documentation and repaired code changes.
Try to cleanup project. Check references of your project and etc.