Second, when the last reference to the workspace is released, the workspace is automatically deleted from the disk.http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//001m00000039000000
public void Construct(IPropertySet props) //this is the function in SOE main file that reads properties { configProps = props; //load properties //.... //Create Scratch Workspace Type factoryType = Type.GetTypeFromProgID( "esriDataSourcesGDB.FileGDBScratchWorkspaceFactory"); IScratchWorkspaceFactory2 scratchWorkspaceFactory = (IScratchWorkspaceFactory2) Activator.CreateInstance(factoryType); //Get default workspace. IWorkspace scratchWorkspace = scratchWorkspaceFactory.DefaultScratchWorkspace; if (scratchWorkspace == null) //create a new one { scratchWorkspace = scratchWorkspaceFactory.CreateNewScratchWorkspace(); } }
/// <summary> /// create a memory workspace /// </summary> /// <returns>memory workspace</returns> public static IWorkspace CreateInMemoryWorkspace() { // Create an in-memory workspace factory. Type factoryType = Type.GetTypeFromProgID( "esriDataSourcesGDB.InMemoryWorkspaceFactory"); IWorkspaceFactory workspaceFactory = (IWorkspaceFactory) Activator.CreateInstance(factoryType); // Create an in-memory workspace. IWorkspaceName workspaceName = workspaceFactory.Create(string.Empty, "memoryWorkspace", null, 0); // Cast for IName and open a reference to the in-memory workspace through the name object. Guid.NewGuid().ToString() IName name = (IName)workspaceName; IWorkspace workspace = (IWorkspace)name.Open(); return workspace; }
I haven't tried your method (perahps you have some reference) but if you want try an alternative method. With InMemory I haven't had problem/// <summary> /// create a memory workspace /// </summary> /// <returns>memory workspace</returns> public static IWorkspace CreateInMemoryWorkspace() { // Create an in-memory workspace factory. Type factoryType = Type.GetTypeFromProgID( "esriDataSourcesGDB.InMemoryWorkspaceFactory"); IWorkspaceFactory workspaceFactory = (IWorkspaceFactory) Activator.CreateInstance(factoryType); // Create an in-memory workspace. IWorkspaceName workspaceName = workspaceFactory.Create(string.Empty, "memoryWorkspace", null, 0); // Cast for IName and open a reference to the in-memory workspace through the name object. Guid.NewGuid().ToString() IName name = (IName)workspaceName; IWorkspace workspace = (IWorkspace)name.Open(); return workspace; }
yes I know InMemory is suitable for little dataset but my suggest is for see if you had lock. I normally create file geodatabase with name _ags_{guid} in output so the are deleted from arcgis server.
IMapServerInit mapServerInit = this.mapServer as IMapServerInit; string pathOutputAGS = (new System.IO.DirectoryInfo(mapServerInit.PhysicalOutputDirectory)).Parent.FullName; string fileName = System.IO.Path.ChangeExtension(string.Format("_ags_{0}", Guid.NewGuid().ToString()), "gdb"); Type factoryType = Type.GetTypeFromProgID( "esriDataSourcesGDB.FileGDBWorkspaceFactory"); IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance (factoryType); IWorkspaceName workspaceName = workspaceFactory.Create(pathOutputAGS, fileName, null, 0); IName name = (IName)workspaceName; IWorkspace workspace = (IWorkspace)name.Open();