This is VB.net rather than C# but you can probably get the process
First import the libraries you need :e.g.
Imports ESRI.ArcGIS.esriSystem
Imports ESRI.ArcGIS.ArcMapUI
Imports ESRI.ArcGIS.Carto
etc.
Then create an application :
Private m_App As ESRI.ArcGIS.Framework.IApplication
Instantiate and create a document with some data sources :
Public Sub StartArcMap()
If m_pDoc Is Nothing Then
System.Windows.Forms.Cursor.Current = Cursors.WaitCursor
'Start arcmap
'm_pDoc = New MxDocumentClass
Dim FrameDoc As ESRI.ArcGIS.Framework.IDocument = New
ESRI.ArcGIS.ArcMapUI.MxDocumentClass()
m_App = FrameDoc.Parent
m_App.Visible = True
Dim pDoc As IDocument = m_App.Document()
Dim pMxDoc As IMxDocument = CType(pDoc, IMxDocument)
'Show arcmap
m_App.Visible = True
'Disable and enable buttons
cmdStartArcMap.Enabled = False
cmdAddData.Enabled = True
cmdQuitArcMap.Enabled = True
System.Windows.Forms.Cursor.Current = Cursors.Default
Dim pActiveView As IActiveView
pActiveView = pMxDoc.ActiveView
Dim pFLayer As IFeatureLayer
pFLayer = New FeatureLayer
'Dim pFClass As IFeatureClass
Dim pShpWSF As GxShapefileFactory
pShpWSF = New GxShapefileFactory
Dim DataPath As String
DataPath = **"C:\DATA STUFF"**
'DataPath = **"SOME WHERE"**
'AddShapeFile(DataPath, m_pApp, pMxDoc, pActiveView)
AddData(m_App, DataPath)
End If
End Sub
Finally create the MXd and add the data :
Public Sub AddData(ByRef m_Application, Datapath)
Dim objFactory As IObjectFactory = TryCast(m_Application,
IObjectFactory)
'Use reflection to get ClsID of ShapefileWorkspaceFactory.
Dim shpWkspFactType As Type = GetType(ShapefileWorkspaceFactoryClass)
Dim typeClsID As String = shpWkspFactType.GUID.ToString("B")
Dim workspaceFactory As IWorkspaceFactory =
DirectCast(objFactory.Create(typeClsID), IWorkspaceFactory)
Dim featureWorkspace As IFeatureWorkspace =
DirectCast(workspaceFactory.OpenFromFile(Datapath, 0),
IFeatureWorkspace)
Dim MxDType As Type = GetType(IMxDocument)
Dim MxDClsID As String = MxDType.GUID.ToString("B")
'Dim pMxDoc As IMxDocument = DirectCast(objFactory.Create(MxDClsID),
IMxDocument)
Dim pMxDoc As IMxDocument = CType(m_App.Document, IMxDocument)
Dim featureLayer As IFeatureLayer =
DirectCast(objFactory.Create("esriCarto.FeatureLayer"), IFeatureLayer)
featureLayer.FeatureClass = featureWorkspace.OpenFeatureClass("wPoints")
featureLayer.Name = featureLayer.FeatureClass.AliasName
'Add the layer to the document.
Dim document As IBasicDocument = DirectCast(m_Application.Document,
IBasicDocument)
document.AddLayer(featureLayer)
document.UpdateContents()
Dim pFClass As IFeatureClass
pFClass = featureWorkspace.OpenFeatureClass("wPoints")
'pFClass = featureLayer.FeatureClass
Dim pFeature As IFeature = pFClass.GetFeature(20)
That should be enough to see how one gets a handle on the Application, the Mxd, data and objects there in?