I hate multiple posting this, but it looks like you've managed to make happen what I've been trying to get accomplished. I'm stuck getting the following error when I try and create the feature class:(http://forums.arcgis.com/threads/25560-IFeatureWorkspace.CreateFeatureClass()-error-(C-))Attempted to read or write protected memory. This is often an indication that other memory is corruptthing is that if I break my code just after the gdb is created I am able to use the system to create the feature class, so I know the memory is actually fine. my code for creation of the fc follows:
public void LoadPoints(IArray parsedcsv)
{
String jobnumber = "job_" + GetJobNumFromCSV(this.filename);
Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
IWorkspaceFactory2 workspaceFactory = (IWorkspaceFactory2)Activator.CreateInstance(factoryType);
IWorkspace ws = workspaceFactory.OpenFromFile(outlocation + jobnumber + ".gdb", 0);
IFeatureWorkspace gdb = (IFeatureWorkspace)ws;
for(int i= 0; i < parsedcsv.Count; i++)
//foreach (String[] record in parsedcsv)
{
String[] record = (String[])parsedcsv.get_Element(i);
String outputlocation = "C:\\Documents and Settings\\lbadgerow\\Desktop\\ParseCSVTEST\\";
String outfile = "";
if (record.Length > 4)
{
String pointtype = record.GetValue(4).ToString(); //hard coded value for column of type
String rec = record.ToString();
switch (pointtype)
{
case ("MP"):
outfile = outputlocation + pointtype + ".txt";
StreamWriting(pointtype, outfile, record, gdb);
break;
case ("BV"):
outfile = outputlocation + pointtype + ".txt";
StreamWriting(pointtype, outfile, record, gdb);
break;
case ("WT"):
outfile = outputlocation + pointtype + ".txt";
StreamWriting(pointtype, outfile, record, gdb);
break;
case ("VL"):
outfile = outputlocation + pointtype + ".txt";
StreamWriting(pointtype, outfile, record, gdb);
break;
case ("FH"):
outfile = outputlocation + pointtype + ".txt";
StreamWriting(pointtype, outfile, record, gdb);
break;
case ("TP"):
outfile = outputlocation + pointtype + ".txt";
StreamWriting(pointtype, outfile, record, gdb);
break;
}
}
else
{
//IN THE EVENT THAT THE 4TH COLUMN IS NULL, ASSUME THAT IT'S A WATER TRACE POINT.
String pointtype = "WT";
outfile = outputlocation + pointtype + ".txt";
StreamWriting(pointtype, outfile, record, gdb);
}
}
}
private IFeatureClass CreateFeatureClass(String pointtype, IFeatureWorkspace workspace)
{
IFeatureClass outfc;
IFields outfields = CreateFields();
var CLSID = new UIDClass();
CLSID.Value = "esriGeodatabase.Feature";
try
{
outfc = workspace.CreateFeatureClass(pointtype, outfields, CLSID, null, esriFeatureType.esriFTSimple, "SHAPE", "");
}
catch (Exception exc)
{
MessageBox.Show(String.Format("Error {0}", exc.Message));
throw new Exception(String.Format("Error {0}", exc.Message));
}
return outfc;
}
private void StreamWriting(String pointtype, String outfile, String[] record, IFeatureWorkspace workspace)
{
String finalstring = "";
int recodLength = record.Length;
IFeatureClass outfc = CreateFeatureClass(pointtype, workspace);
for (int a = 0; a < record.Length; a++)
{
if (a > 0)
{
String value = record.ElementAt(a);
if (finalstring.Equals(""))
{
if (!value.Equals(""))
{
finalstring = value + ",";
}
}
else
{
if (!value.Equals(""))
{
finalstring += value + ",";
}
}
}
}
finalstring.TrimEnd(',');
if (!File.Exists(outfile))
{
StreamWriter streamWriter = new StreamWriter(outfile);
streamWriter.WriteLine(finalstring);
streamWriter.Close();
}
else
{
//append to feature class
StreamWriter streamWriter = File.AppendText(outfile);
streamWriter.WriteLine(finalstring);
streamWriter.Close();
}
}
I did find the following information about an issue with the IList<T> and ICollection<T> interfaces causing issues in the DOTNET 2.0 framework:http://support.microsoft.com/kb/971030But I would think that switching to using ESRI.ArcGIS.esriSystem.IArray would clear that up, unless IArray inherits from ICollection as well.At this point (I've been on this hang up for 2+ weeks now) I'm waiting on getting my global account squared with the company that I'm working for now so that I can submit a support ticket, so ANY advice is going to be greatly appreciated. I'd be extremely happy if someone found a simple typo in my code was the culprit.