Select to view content in your preferred language

Unable to add rasters to programmatically created maps while debugging

937
6
02-18-2020 04:48 PM
KarenMeinstein
Regular Contributor

I've encountered a strange issue and I wonder if anyone else has had this problem.  I'm using Visual Studio 2015 and ArcGIS Pro 2.5 (although I had the same problem in 2.4.3 and maybe earlier).

My code creates a map programmatically as follows:

await QueuedTask.Run(() =>
{

         Map myMap = MapFactory.Instance.CreateMap("My Map");

});

and then opens the map in Pro like this:

await QueuedTask.Run(async () =>
{

        await ProApp.Panes.CreateMapPaneAsync(myMap, myMapExtent);

});

All of this works fine.  However if I'm running from VS, once the new map has been created, if I try to manually add a raster to the map, I get an error saying "Failed to add data, unsupported data type."  In addition, if I then (while in the same debugging session) try to add a raster to ANY map, even if I create a new project and manually add a map, I get the same error.  I've tried both .img and .tif rasters and gotten the same result.  I have to close and reopen Pro to make adding rasters work correctly.

Also, if while running from VS I add a new map manually before having my code create a map programmatically, and manually add a raster to that map (again before my code creates a map), then I can add rasters with no problem to my programmatically created map!

However, if I rebuild my solution in VS and then open Pro separately (i.e., not from VS, so not debugging) I'm able to add rasters to my programmatically created maps with no problem.

I wonder if this is a problem with Pro or with VS or maybe something in my particular setup.

0 Kudos
6 Replies
UmaHarano
Esri Regular Contributor

Hi Karen

I am not seeing this issue  - I am testing this on Pro version 2.4. Is there a small sample raster file you could share?

I am creating a map and opening the Map pane in one button click like the code below. Is this similar to what you are doing?

//Button's OnClick method
protected async override void OnClick()
        {
            await QueuedTask.Run(async () =>
            {
                var map = MapFactory.Instance.CreateMap("MyMap", basemap: Basemap.ProjectDefault);
                await ProApp.Panes.CreateMapPaneAsync(map, MapViewingMode.Map);

            });
        }
0 Kudos
KarenMeinstein
Regular Contributor

Hi Uma,

Thanks for your response.  Yes, that's what I'm doing.  I even created a new button with just your code in it, and tried it and still had the same problem.  I'm tempted to go back to 2.4 and see if this still happens.  I'm happy to share a raster with you, but I don't see anyplace to add an attachment.

Karen

0 Kudos
UmaHarano
Esri Regular Contributor

Hi Karen

I am afraid the Attach button is a hidden feature  I see it if I click the "Use Advanced editor" button at the top.

0 Kudos
KarenMeinstein
Regular Contributor

Here is a raster to try, but I don't think it will make a difference.  I'm starting to think there is something weird in my visual studio setup.  I went back to Pro 2.4 and I was still having the problem.  Thanks for your help with this.

0 Kudos
UmaHarano
Esri Regular Contributor

I tried with 2.4.3 also - I couldn't see the issue with the attached data.  Also FYI - Pro version 2.4 onward, Pro SDK supports Visual Studio 2017 and 2019 only.

0 Kudos
KarenMeinstein
Regular Contributor

Oh, I didn't know that!  I bet if I upgrade VS the problem will stop happening!  Thanks!

0 Kudos