Solved! Go to Solution.
Can't really help unless we see the code.
I suggest you upload a sample of code where this null is being returned.
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 } } }
OK here is an idea, go to the the Config.esriaddinx file in Visual Studio and set the autoLoad to equal "true" for your <Extension>.
<ESRI.Configuration xmlns="http://schemas.esri.com/Desktop/AddIns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Name>TestChargementAddIn</Name> <AddInID>{b60275b3-d9ad-48fe-90ad-d7f43adfbb6c}</AddInID> <Description>C'est un test sur le chargement d'un AddIn.</Description> <Version>1.0</Version> <Image>Images\TestChargementAddIn.png</Image> <Author>siwang</Author> <Company>Kleegroup</Company> <Date>18/06/2014</Date> <Targets> <Target name="Desktop" version="10.2" /> </Targets> <AddIn language="CLR4.5" library="TestChargementAddIn.dll" namespace="TestChargementAddIn"> <ArcMap> <Extensions> <Extension id="Kleegroup_TestChargementAddIn_ExtensionChargement" class="ExtensionChargement" productName="Extension du Chargement" showInExtensionDialog="true" autoLoad="true"> <Description>Test sur l'extension</Description> </Extension> </Extensions> </ArcMap> </AddIn> </ESRI.Configuration>
You said you compiled the addin in 10.2.1 and are trying to run it on 10.2.0. I don't know about addins but that doesn't typically work for standard COM extensions since ArcObjects are not backwards compatible.
I've always understood development with ArcObjects should use be using the 3.5 .Net Framework, I see you have yours set to 4.5. You can change this under project properties > Compile > Advanced Compile Options.
Also make sure platform Target CPU is x86.
Thank you for this important information. Effectively, we have also a doubt on the compatibility.
Our client finally agrees to update their application to the version of 10.2.1. However, we have to assure that there is nothing else which could go wrong beside the version problem.