Why ArcMap.Application.Document is null on run? There is my addin. It consist of tool and docWindow. DocWindow opens when tool is selected. When I run ArcMap with selected myTool and opened window, ArcMap.Application.Document is null.
If I call this from DockPanelClass (or other class) :
<SPAN class="typ" style="font-size: 12.222222328186px; color: #2b91af;">IMxDocument</SPAN><SPAN class="pln" style="font-size: 12.222222328186px; color: #000000;"> doc </SPAN><SPAN class="pun" style="font-size: 12.222222328186px; color: #145680;">=</SPAN><SPAN class="pln" style="font-size: 12.222222328186px; color: #000000;"> </SPAN><SPAN class="typ" style="font-size: 12.222222328186px; color: #2b91af;">ArcMap</SPAN><SPAN class="pun" style="font-size: 12.222222328186px; color: #145680;">.</SPAN><SPAN class="typ" style="font-size: 12.222222328186px; color: #2b91af;">Application</SPAN><SPAN class="pun" style="font-size: 12.222222328186px; color: #145680;">.</SPAN><SPAN class="typ" style="font-size: 12.222222328186px; color: #2b91af;">Document</SPAN><SPAN class="pln" style="font-size: 12.222222328186px; color: #000000;"> </SPAN><SPAN class="kwd" style="font-size: 12.222222328186px; color: #8a4a0b;">as</SPAN><SPAN class="pln" style="font-size: 12.222222328186px; color: #000000;"> </SPAN><SPAN class="typ" style="font-size: 12.222222328186px; color: #2b91af;">IMxDocument</SPAN><SPAN class="pun" style="font-size: 12.222222328186px; color: #145680;">;</SPAN><SPAN class="pln" style="font-size: 12.222222328186px; color: #000000;"> </SPAN><SPAN class="typ" style="font-size: 12.222222328186px; color: #2b91af;">IMap</SPAN><SPAN class="pln" style="font-size: 12.222222328186px; color: #000000;"> </SPAN><SPAN class="typ" style="font-size: 12.222222328186px; color: #2b91af;">map</SPAN><SPAN class="pln" style="font-size: 12.222222328186px; color: #000000;"> </SPAN><SPAN class="pun" style="font-size: 12.222222328186px; color: #145680;">=</SPAN><SPAN class="pln" style="font-size: 12.222222328186px; color: #000000;"> doc</SPAN><SPAN class="pun" style="font-size: 12.222222328186px; color: #145680;">.</SPAN><SPAN class="typ" style="font-size: 12.222222328186px; color: #2b91af;">FocusMap</SPAN><SPAN class="pun" style="font-size: 12.222222328186px; color: #145680;">;</SPAN>
map contains 0 layers;
But when I call it from MyToolClass it becomes valid and contains all my map layers. What happens?