AnsweredAssumed Answered

I am trying to do Focusmap method using C# in Visual Studio. But its throwing me error "Unable to cast COM Objects".

Question asked by p.crishi on Oct 9, 2017

Here's my code :-

protected override void OnClick()         {             

              IMxDocument mxDocument;  

            mxDocument = (IMxDocument)ArcMap.Application.Document;          

            IMap map;             

            map = mxDocument.FocusMap;                      

            ILayer layer = map.get_Layer(0);            

            String name = layer.Name;            




On "map=mxDocument.FocusMap;" line, it is showing me Error: Cannot implicitly convert type "ESRI.ArcGIS.Carto.IMap" to "Myproject.IMap". An explicit conversion exists (are you missing a cast?)


I got struck with this.. Please someone help me...