Referencing ArcMap in class library using ArcObjects?
If you need to create an Application reference then you can create an IMxDocument object which will create a new Application object.
http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriArcMapUI/MxDocument.htm
If you want an existing ArcMap reference you can use AppROT like so:
AppROT appRot = new AppROT();
//appRot.Item[#] gives a reference to all Arc applications currently running
appRot.get_Item(0);
IApplication myApp = appRot.get_Item(0) as IApplication;
IMxDocument mxdoc = myApp.Document as IMxDocument;
I have got this to work, but not using AppRot (one problem is that there could be multiple instances of ArcMap and ArcCatalog), but to just pass the ArcGIS application object from the addin.
Within Addin
public ESRI.ArcGIS.ArcMap.Application arcmap = ArcMap.Application as ESRI.ArcGIS.ArcMap.Application;
Within class library
public bool isEditing(ESRI.ArcGIS.ArcMap.Application arcMap)
{
UID editorUID = new UIDClass();
editorUID.Value = "esriEditor.Editor";
IExtension editor = arcMap.FindExtensionByCLSID(editorUID);// (editorUID);// '//as IEditor3;
IEditor e = editor as IEditor;
if (e.EditState == esriEditState.esriStateNotEditing)
{
return false;
}
else
{
return true;
}
}