Can't really help unless we see the code.
I suggest you upload a sample of code where this null is being returned.
Hello Hornbydd,Thank you for your message. Here is the code :
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
namespace TestChargementAddIn {
public class ExtensionChargement : ESRI.ArcGIS.Desktop.AddIns.Extension {
public ExtensionChargement() {
}
protected override void OnStartup() {
//
// TODO: Uncomment to start listening to document events
//
// WireDocumentEvents();
if (ArcMap.Application == null) {
// relative path est par rapport au répertoire de Debug ou Release
MessageBox.Show("Erreur : ArcMap.Application est nul !!");
} else {
MessageBox.Show("OK: L'AddIn est chargé normalement. ArcMap.Application : " + ArcMap.Application.Caption.ToString());
if (ArcMap.Document == null) {
MessageBox.Show("Erreur : ArcMap.Document est nul !!");
} else {
MessageBox.Show("OK : ArcMap.Document non nul");
}
}
}
private void WireDocumentEvents() {
//
// TODO: Sample document event wiring code. Change as needed
//
// Named event handler
ArcMap.Events.NewDocument += delegate() { ArcMap_NewDocument(); };
// Anonymous event handler
ArcMap.Events.BeforeCloseDocument += delegate() {
// Return true to stop document from closing
ESRI.ArcGIS.Framework.IMessageDialog msgBox = new ESRI.ArcGIS.Framework.MessageDialogClass();
return msgBox.DoModal("BeforeCloseDocument Event", "Abort closing?", "Yes", "No", ArcMap.Application.hWnd);
};
}
void ArcMap_NewDocument() {
// TODO: Handle new document event
}
}
}
I've also uploaded the packaged Add-In in the post in order that you could test it.Thanks.Siqin