Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to read a csv file straight into a set of new feature classes within a new file geodatabase, but I am getting the following stack trace when it fails:

Attempted to read or write protected memory. This is often an indication that other memory is corrupt. ESRI.ArcGIS.Geodatabase at ESRI.ArcGIS.Geodatabase.IFeatureDataset.CreateFeatureClass(String Name, IFields Fields, UID CLSID, UID EXTCLSID, esriFeatureType FeatureType, String ShapeFieldName, String ConfigKeyword) at WaterEditorExtension.Model.SurveyUtilities.StreamWriting(String pointtype, String outfile, String[] record, IWorkspace workspace) in C:\Documents and Settings\lbadgerow\My Documents\Visual Studio 2008\Projects\WaterEditorExtension\WaterEditorExtension\Model\SurveyUtilities.cs:line 206.

I believe that it is related to a schema lock, but I am able to create a feature dataset which is confusing. (In proper stacktrace form, below is my workspace factory call, and my where I'm building the FC)

        public IWorkspace CreateFileGdbWorkspace(String path, String jobnumber)
        {
            Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
            IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);

            IWorkspaceName workspaceName = workspaceFactory.Create(path, jobnumber, null, 0);

            IName name = (IName)workspaceName;
            IWorkspace workspace = (IWorkspace)name.Open();
            return workspace;
        }
...
IFeatureWorkspace featwork = (IFeatureWorkspace)workspace;
featwork.CreateFeatureClass("test", outfields, CLSID, null, esriFeatureType.esriFTSimple, "SHAPE", "");

EDIT 17 March 2011: has anyone attempted to Thread a component (extension) of ArcMap? I'm thinking that I could release the schema lock that is preventing this from moving on to the FC creation phase of this project, but I can't seem to get ArcMap to remain stable when I create a new thread to build the gdb.

share|improve this question
I had some issues that where solved by making sure that garbage collection don't remove objects that are sharing state between COM object. You could try making some of the variables static and release those after you finishing the whole operation? – MathiasWestin Mar 10 '11 at 20:06
Thanks Mathias. I've actually got CreateFileGDBWorkspace() set as a static method now, but it's giving me the same respone. I went so far as to "slum it" and tried creating a shapefileworkspacefactory but got the same results, I got as far as throwing a COMException yesterday but I was trying to rule out the chance that I was passing invalid fields (using IFieldChecker) – Luke Mar 11 '11 at 13:26
UPDATE: I'm building the geodatabase in a background thread now, and when I reclaim that thread I am without a lock on the geodatabase, however I'm still having the issue when I use the wsfactory to open the gdb so that I can create the new fc's – Luke Mar 23 '11 at 14:33
UPDATE: It's looking like there is a flaw in the .NET framework around the IList<T> and ICollection<T> that causes the excption in my case. I was able to create a workflow with python that takes care of the data creation and import. The only hitch is that you have to call the python script as a new Process() from within the application. email me if you are interested in the code/ workaround. good luck – Luke Mar 30 '11 at 15:33

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.