MemoryConnectionProperties custom name vs. ExecuteTool in memory

335
3
Jump to solution
09-16-2021 11:21 PM
ole1986
New Contributor III

I am trying to get a memory geodatabase with custom name to work with Geo processing tools (executed in codebehind).

So, I have created a `MemoryConnectionProperties` object as follow

MemoryConnectionProperties _memoryConnectionProperties = new MemoryConnectionProperties("MyCustomName");

 

But yet I could not find out how to access it using `ExecuteToolAsync`?

Usually for memory I have used the following

var parameters = Geoprocessing.MakeValueArray("memory\\" + _targetFeatureClass.GetName(), shapeFileOutputDir, shapeFileOutputName);
var result = await Geoprocessing.ExecuteToolAsync("FeatureClassToFeatureClass", parameters, null, null, null, GPExecuteToolFlags.None);

Which is fine with the default memory.

Since I would want to isolate several "tasks" the idea came up to use a custom memory name. But I could not find out how to define the memory location (with its custom name).

What I have tried without success

// does not work when executing "FeatureToFeatureClass" tool
var parameters = Geoprocessing.MakeValueArray("memory\\MyCustomName\\" + _targetFeatureClass.GetName(), shapeFileOutputDir, shapeFileOutputName);
// also does not work when executing "FeatureToFeatureClass" tool
var parameters = Geoprocessing.MakeValueArray("MyCustomName\\" + _targetFeatureClass.GetName(), shapeFileOutputDir, shapeFileOutputName);

Any ideas how to solve it?

0 Kudos
1 Solution

Accepted Solutions
RichRuh
Esri Regular Contributor

Sorry, geoprocessing can only access the memory geodatabase called "memory."  

--Rich

View solution in original post

0 Kudos
3 Replies
RichRuh
Esri Regular Contributor

Sorry, geoprocessing can only access the memory geodatabase called "memory."  

--Rich

0 Kudos
dkuida
by
New Contributor II

Any intention to allow it to work custom named instances?

it is much easier to create a temp named instance than to manage create and destroy memory instances

0 Kudos
RichRuh
Esri Regular Contributor

While I don't work on the geoprocessing team, I have not heard of any plans.

There really shouldn't be any problem working with the default ("memory") memory geodatabase. If you're concerned about memory usage, you could always delete the tables that you have created when you are finished with them.

Creation is a bit tricky at the moment, because the code to do so is different depending on whether or not you have run a geoprocessing tool using "memory" already.  Here's the workaround we shared at DevSummit:

Geodatabase geodatabase;

try {

  geodatabase = new Geodatabase(new MemoryConnectionProperties());

}

catch {

  geodatabase = SchemaBuilder.CreateGeodatabase(newMemoryConnectionProperties());

}

(We're fixing this at 3.1)

0 Kudos