|
POST
|
In regards to the upgrade of the Pro SDK, if you installed from the market place you should see the 'upgrade available' note under 'manage extensions'. If you configured 'automatically update' (see below) it should automatically update once we upload a new release to the market place. You can find more on updates here: https://github.com/Esri/arcgis-pro-sdk/wiki/ProGuide-Installation-and-Upgrade#upgrade-arcgis-pro-sdk-for-net
... View more
03-26-2020
11:14 AM
|
1
|
0
|
2242
|
|
POST
|
Hi Lars, I wrote a CoreHost sample storing data in either an SDE or File Geodatabase. i am using the RowBuffer as you do, Here is the main method writing the data: I write a few hundred records with no problems. But the data i am writing is static and doesn't come from another feature class or table. private static void FeatureWrite(string gdbPath, string fcName, string writeJson)
{
var theWriteInfoJson = System.IO.File.ReadAllText(writeJson);
var writeIt = JsonConvert.DeserializeObject<WriteFieldInfo[]>(theWriteInfoJson);
int count = 0;
Host.Initialize();
DatabaseConnectionFile dbConnection = null;
FileGeodatabaseConnectionPath gdbConnection = null;
if (System.IO.Path.GetExtension(gdbPath).ToLower().Equals(".sde"))
{
dbConnection = new DatabaseConnectionFile(new Uri(gdbPath));
}
else
{
gdbConnection = new FileGeodatabaseConnectionPath(new Uri(gdbPath));
}
using (Geodatabase geodatabase = dbConnection != null ? new Geodatabase(dbConnection) : new Geodatabase(gdbConnection))
{
using (FeatureClass writeFeatureClass = geodatabase.OpenDataset<FeatureClass>(fcName))
{
geodatabase.ApplyEdits(() =>
{
RowBuffer rowBuffer = null;
Row row = null;
try
{
FeatureClassDefinition featureDefinition = writeFeatureClass.GetDefinition();
int lenghtIndex = featureDefinition.FindField("LENGTH");
double baseX = 577059;
double baseY = 3620749;
double baseZ = 0;
Coordinate3D coord1 = new Coordinate3D(baseX, baseY, baseZ);
Coordinate3D coord2 = new Coordinate3D(baseX + 100, baseY + 100, baseZ);
List<Coordinate3D> primCoords = new List<Coordinate3D>();
primCoords.Add(coord1);
primCoords.Add(coord2);
PolylineBuilder primLineBuilder = new PolylineBuilder(primCoords);
primLineBuilder.HasZ = true;
while (count < MaxWriteRows)
{
using (rowBuffer = writeFeatureClass.CreateRowBuffer())
{
// Either the field index or the field name can be used in the indexer.
rowBuffer[writeFeatureClass.GetDefinition().GetShapeField()] = primLineBuilder.ToGeometry();
for (int idx = 0; idx < writeIt.Length; idx++)
{
var writeFieldInfo = writeIt[idx];
if (string.IsNullOrEmpty(writeFieldInfo.stringValue))
{
rowBuffer[writeFieldInfo.fieldName] = writeFieldInfo.intValue;
}
else
{
rowBuffer[writeFieldInfo.fieldName] = writeFieldInfo.stringValue;
}
}
row = writeFeatureClass.CreateRow(rowBuffer);
count++;
}
}
}
catch (GeodatabaseException exObj)
{
Console.Error.WriteLine(exObj);
}
finally
{
if (row != null)
row.Dispose();
}
});
}
}
} I can see two differences: 1) the use of geodatabase.ApplyEdits(() => {} ... 2) i don't dispose the row created with CreateRow - but as Rich Ruh pointed out to me your code looks correct in that regard. So i changed my code to this: using (row = writeFeatureClass.CreateRow(rowBuffer))
{
// more work using row
} All my tests worked fine.
... View more
03-26-2020
10:31 AM
|
2
|
1
|
3252
|
|
POST
|
Can you email me (Wolf Kaiser) the project that you re-targeted to .Net 4.8 and it still held the broken references? I will take a look. As to the market place not showing the update notification this is being tested with each release, so i am not sure why you wouldn't get the notification.
... View more
03-26-2020
09:51 AM
|
0
|
2
|
2242
|
|
POST
|
Hi Vidmas, Can you please clarify 'everything broke'. What errors did you get? Did you re-target your project file to the 4.8 .Net framework? The "Pro Fix References" utility only needs to be used if you change the installation location of Pro. As for the 'updates available' for the Pro SDK, this assumes that you initially installed the Pro SDK from the market place, if you manually install the SDK you will not get the upgrade available message in Visual Studio.
... View more
03-26-2020
08:28 AM
|
0
|
4
|
2242
|
|
POST
|
Hi Lars, I will write a sample using your code snippet in ArcGIS Pro 2.5 and let you know what i find - sorry i ran out of time today but i'll do it first thing in the morning. Just to make sure when you compiled the project under 2.5 you did change the .Net framework to 4.8? 4.8 is a new requirement for 2.5. https://community.esri.com/groups/arcgis-pro-sdk/blog/2020/02/07/at-pro-25-the-net-framework-is-changed-to-48 - Wolf
... View more
03-25-2020
04:38 PM
|
0
|
1
|
3252
|
|
POST
|
Hi David, It turns out the problem (no user/password in the .sde connection file) has been fixed in ArcGIS Pro 2.6. 2.6 is properly prompting for user/password entry when the attempt is made to open the geodatabase. However, both 2.4 and 2.5 throw an exception (dialog cancelled) instead. Below is a workaround code snippet (2.5) which prompts the user for username/password entry if a username/password has not been support in the .sde connection file. I use a ProWindow to get the user/password string. I attached the complete vs 2019 project. protected override async void OnClick()
{
try
{
// this connection file has no user/password entered
var sdeCon = new DatabaseConnectionFile(new Uri(@"C:\Users\wlfka\Documents\ArcGIS\Projects\MyTestSDe2\localhost.sde"));
var sdeConProperties = DatabaseClient.GetDatabaseConnectionProperties(sdeCon);
if (string.IsNullOrEmpty(sdeConProperties.User))
{
// prompt for username / password using a ProWindow
var userPwDlg = new AddInDatabaseConnection();
Module1.ConnectionString = $@"{sdeConProperties.AuthenticationMode} {sdeConProperties.Instance} {sdeConProperties.Database}";
userPwDlg.Owner = FrameworkApplication.Current.MainWindow;
userPwDlg.Closed += (o, e) => { };
var dlgResult = userPwDlg.ShowDialog();
if (Module1.HasCredentials == false) return;
sdeConProperties.User = Module1.UserName;
sdeConProperties.Password = Module1.Password;
}
var hasConnected = await QueuedTask.Run(() =>
{
bool bConnected = false;
try
{
using (Geodatabase sqlServerGeodatabase = new Geodatabase(sdeConProperties))
{
IReadOnlyList<Definition> fcList = sqlServerGeodatabase.GetDefinitions<FeatureClassDefinition>();
foreach (var fc in fcList)
System.Diagnostics.Debug.WriteLine(fc.GetName());
// Use the geodatabase.
bConnected = true;
}
}
catch (Exception ex)
{
MessageBox.Show($@"Unable to connect: {sdeCon}");
}
return bConnected;
});
if (hasConnected) MessageBox.Show("Connected");
}
catch (Exception ex)
{
MessageBox.Show($@"Error: {ex.ToString()}");
}
} In essence the code parses the connection properties from the .sde file and then prompt for credential input. It then uses the connection properties to connect and not the .sde file. ProWindow saves the user/password in the module class and then closes. i then user the connection properties to open the geodatabase.
... View more
03-25-2020
04:32 PM
|
2
|
6
|
3360
|
|
POST
|
I tried this in ArcGIS Pro 2.4 and see that the exception is being thrown in the GeoDatabase constructor. However, i don't get the hanging issue, probably because i used QueuedTask.Run .... I will report this to the dev team and check if there's a workaround for this. Thanks, Wolf
... View more
03-24-2020
04:29 PM
|
0
|
0
|
3360
|
|
POST
|
I cannot duplicate your problem. Using QueuedTask.Run is not optional in an add-in. I am running the code snippet above using Pro 2.5 without any problems. What version of Pro are you using and how did you create the .sde connection files (what version of Pro) ?
... View more
03-24-2020
03:29 PM
|
0
|
0
|
3360
|
|
POST
|
I don't see this in your code, maybe you have this in the calling function, but you must run "new GeoDatabase" from within the context of QueuedTask.Run. You should see the following text in the help/intellisense string: "This method must be called on the MCT. Use QueuedTask.Run." Whenever you see this you have to use QueuedTask.Run. In terms of code it should look like this: QueuedTask.Run(() =>
{
var sdeCon = new DatabaseConnectionFile(new Uri(@"C:\Data\connection.sde"));
using (Geodatabase sqlServerGeodatabase = new Geodatabase(sdeCon))
{
// Use the geodatabase.
}
});
... View more
03-24-2020
08:22 AM
|
1
|
2
|
3360
|
|
POST
|
Hi Karsten, what is the workflow that you try to accomplish, in order words what event triggers the MessageBox that occurs with the 'Closing Project' message box?
... View more
03-24-2020
07:45 AM
|
0
|
2
|
2898
|
|
POST
|
Sorry Jaewon, the Pro SDK only supports ArcGIS Pro add-ins and configurations that are using WPF. In addition input forms also require the MVVM (Model-View-ViewModel) pattern. See https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Migrating-to-ArcGIS-Pro#wpf-and-mvvm
... View more
02-27-2020
07:49 AM
|
1
|
0
|
2757
|
|
POST
|
Sorry Daniel, this functionality is not implemented in the Pro API. If i understand your data model correctly you store two object ids: one ID contains the object id of the related table and one ID contains the object id pointing to the related row in the related table. So does the 'related table ID' field contain the same value (or referenced related table name) for all rows, or do some rows refer to a different related table name? I can think of a few alternatives to implement this, but it would help to know some of these details on your data model. Worst case you can add your own stand-alone table that contains an 'object id' and the corresponding table name.
... View more
02-25-2020
02:04 PM
|
0
|
0
|
2361
|
|
POST
|
Hi Timothy, I am looking into this issue right now, but supplying a token (which is not possible via the API) instead of letting ArcGIS Pro do its OAuth popup will not work because once you add a Portal Item to a map, sign in has to be supported out-of-box in order for the Portal item to show up on the map when you for example reopen the project. So i think to fix this problem you have to be able to sign in to ArcGIS Enterprise Portal from ArcGIS Pro even with your disclaimer page. I reached out to our ArcGIS Enterprise dev team and try to get their input on this issue. I will post any progress here.
... View more
02-19-2020
03:50 PM
|
0
|
1
|
3986
|
|
POST
|
Hi Simon, Charlie is out of town so i looked at your issue and found the following: I you search on a portal, let's call this portal 'X', that is not the 'active' portal, let's call the active portal 'Y', the search on portal 'X' works as long as you are signed in on portal 'X'. So far so good. In my sample i am searching and finding a 'Portal Feature Layer' on my portal 'X' (a local Enterprise portal), however, my active portal 'Y' is ArcGIS Online. Below is a screen shot of the portal 'X' item i am trying to add to my map: Your code snippet above is correct, as you have to first create an Item using 'ItemFactory.Instance.Create' by passing in the portal 'X' item's ID and eventually you call 'LayerFactory.Instance.CreateLayer' by passing in that item created by item factory. However, it turns out that both methods: ItemFactory.Instance.Create and LayerFactory.Instance.CreateLayer will not work if the portal 'X' is not the active portal. You can actually observe the same behavior if you take the portal URL of your portal 'X' item and try to add it to your map manually through the 'Add Data from Path' dialog: You will get this error if Portal 'X' is not the active portal. If you change Portal 'X' to be the active portal temporarily then 'Add Data from Path' works fine. So this led me to the following workaround for this issue - by simply changing Portal 'X' to be the active portal until the layer has been created, then restoring the original active portal: private async Task SignInAsync(ArcGISPortal nonActivePortal)
{
var signInResult = await nonActivePortal.SignInAsync();
var pqp = PortalQueryParameters.CreateForItemsOfType(PortalItemType.Layer, "title:fooLayerTitle");
PortalQueryResultSet<PortalItem> results = await ArcGISPortalExtensions.SearchForContentAsync(nonActivePortal, pqp);
//Get the first result
var myPortalItem = results.Results?.OfType<PortalItem>().FirstOrDefault();
FeatureLayer featureLayer = null;
Item testLayer = ItemFactory.Instance.Create(myPortalItem.ID, ItemFactory.ItemType.PortalItem);
// let's try to change the active portal
var currentActivePortal = ArcGISPortalManager.Current.GetActivePortal();
if (testLayer == null && nonActivePortal != currentActivePortal)
{
ArcGISPortalManager.Current.SetActivePortal(nonActivePortal);
testLayer = ItemFactory.Instance.Create(myPortalItem.ID, ItemFactory.ItemType.PortalItem);
}
if (LayerFactory.Instance.CanCreateLayerFrom(testLayer))
{
await QueuedTask.Run(() =>
{
featureLayer = LayerFactory.Instance.CreateLayer(testLayer, MapView.Active.Map, 0) as FeatureLayer;
});
}
// reset the original active portal
if (nonActivePortal != currentActivePortal)
ArcGISPortalManager.Current.SetActivePortal(currentActivePortal);
} i will bring this issue to the attention of our development group. For the time being see if the workaround will suffice. - Wolf
... View more
02-19-2020
11:26 AM
|
2
|
1
|
3408
|
|
POST
|
Hi Richard, When you click the link in the answer it will take you to a snippet that shows the "MapFactory.Instance.CreateMap" method you asked about in your original question. The snippet shows that you have to call the CreateMap method from within the context of the MCT or main CIM thread using QueuedTask.Run. Usually you can see the MCT requirement for any method by looking at the API help for the method or through intellisense (when you hover your mouse pointer over the method name in Visual Studio). The requirement for MCT is listed in the help always like this: "This method must be called on the MCT. Use QueuedTask.Run". So the fix for your snippet would look like this: protected override async void OnClick()
{
Map map = null;
//ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Open");
var mapProjectItems = Project.Current.GetItems<MapProjectItem>();
await QueuedTask.Run(() =>
{
if (mapProjectItems.Count() > 0)
{
var mapProjectItem = mapProjectItems.First();
//FirstOrDefault(mpi => mpi.Name.Equals("World Map"));
map = mapProjectItem.GetMap();
ProApp.Panes.CreateMapPaneAsync(map);
}
else
{
map = MapFactory.Instance.CreateMap("World Map", ArcGIS.Core.CIM.MapType.Map, ArcGIS.Core.CIM.MapViewingMode.Map, Basemap.Terrain);
}
});
}
... View more
02-12-2020
05:42 PM
|
0
|
0
|
5768
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-29-2025 10:48 AM | |
| 1 | 05-24-2021 09:04 AM | |
| 1 | 12-03-2020 08:44 AM | |
| 1 | 10-07-2025 07:27 AM | |
| 2 | 12-29-2025 10:03 AM |
| Online Status |
Offline
|
| Date Last Visited |
05-21-2026
01:59 PM
|