Hello -
I'm trying to create a standalone application that will run from TaskScheduler. So far it accomplishes several tasks fine such as: create a directory, copy a GDB to that directory, import tables into the GDB, create indexes, compact the database and create a fileGeodatabase.
At this point it successfully opens ArcMap, gets a handle on the IApplication, MxDocument etc. The next step is to add a layer. This is when ArcMap CRASHES. ugh!
I've tried to add several different types of layers, but ArcMap still quits on the line:
m_MxDocument.FocusMap.AddLayer(pFeatureLayer);
If anyone has an idea of how to start troubleshooting this, I would greatly appreciate the help.
Thanks, Linda
internal static ILayer AddSDEFeatureClass(string server, string instance, string database,
string user, string password, string version,
string featureClassName, string layerFileName,
string tocName, string groupLayerName,
short transparency, bool labels,
bool visibility, bool selectability)
{
//Purpose: Adds an SDE feature class to the active map frame.
try
{
IActiveView pActiveView = m_MxDocument.ActiveView as IActiveView;
IMap pMap = m_MxDocument.FocusMap;
IPropertySet pPropertySet = new PropertySetClass();
pPropertySet.SetProperty("SERVER", server);
pPropertySet.SetProperty("INSTANCE", instance);
pPropertySet.SetProperty("DATABASE", database);
pPropertySet.SetProperty("USER", user);
pPropertySet.SetProperty("PASSWORD", password);
pPropertySet.SetProperty("VERSION", version);
IWorkspaceFactory pWorkspaceFactory = new SdeWorkspaceFactoryClass();
IFeatureWorkspace pFeatureWorkspace = pWorkspaceFactory.Open(pPropertySet, 0) as IFeatureWorkspace;
IFeatureClass pFeatureClass = pFeatureWorkspace.OpenFeatureClass(featureClassName);
IFeatureLayer pFeatureLayer = new FeatureLayerClass();
pFeatureLayer.FeatureClass = pFeatureClass;
m_MxDocument.FocusMap.AddLayer(pFeatureLayer); CRASH HAPPENS HERE !
......