locked
Exception: Customization could not be loaded because the application domain could not be created (VS2010/ EXCEL 2010) RRS feed

  • Question

  • Hi,

    I am working on an add in project for Excel 2010 using VS 2010. The project was working fine on Excel 2010.

    Recently, I migrated the project from .NET 3.5/.NET 2.0 to .NET 4 and fixed compilation and compatibility errors (see these links: https://social.msdn.microsoft.com/Forums/en-US/exceldev/thread/3e805dc2-0577-4d07-9f12-b812e8101ac2/., https://social.msdn.microsoft.com/Forums/en-US/exceldev/thread/9ce47bad-2ac0-4884-947a-a0e1f8d75349/ ). Now I can have successful builds.

    The problem is that the add in doesn't appear anymore on Excel 2010. I have checked File>Options>Add ins on Excel and the add in seems to be inactif:

    In addition the Add in doesn't exist on the disabled items list. Also when I go to Manage> COM Add ins> GO I get this:

    And When I set vsto_suppressdisplayalerts variable path to 0 and changing LoadBehavior to 3 on the registery and launch Excel, I get the following Exception:

    La personnalisation n'a pas pu être chargée, car le domaine d'application n'a pas pu être créé.
    
    
    ************** Texte de l'exception **************
    Microsoft.VisualStudio.Tools.Applications.Runtime.CannotCreateCustomizationDomainException: La personnalisation n'a pas pu être chargée, car le domaine d'application n'a pas pu être créé. ---> System.BadImageFormatException: Impossible de charger le fichier ou l'assembly 'Sage Reports Extra Addin, Version=0.0.0.84, Culture=neutral' ou une de ses dépendances. Cet assembly a été construit par un runtime plus récent que le runtime actuellement chargé et ne peut pas être chargé.
    Nom du fichier : 'Sage Reports Extra Addin, Version=0.0.0.84, Culture=neutral'
       à System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
       à System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
       à System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
       à System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
       à System.Reflection.Assembly.Load(String assemblyString)
       à Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.DomainInitializer.ActivatePipeline(String addInAssembly, String addInClass, String[] pipelineInfo)
       à Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.DomainInitializer.StartAddIn(IntPtr hostServiceProvider, String[] pipeline, String assemblyName, String[] entryPoints)
       à Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.DomainInitializer.StartAddIn(IntPtr hostServiceProvider, String[] pipeline, String assemblyName, String[] entryPoints)
       à Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.LoadMafPipeline(AppDomain newDomain, IntPtr hostServiceProvider, String fullAssemblyName, String[] entryPoints, OfficeApp officeApplication, OfficeVersion officeVersion, IntPtr& executor)
       à Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.CreateCustomizationDomainInternal(String solutionLocation, String manifestName, String documentName, Boolean showUIDuringDeployment, IntPtr hostServiceProvider, Boolean useFastPath, IntPtr& executor)
    
    Gestionnaire des assemblys chargé à partir de :  C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
    Exécution sous l'exécutable  C:\Program Files\Microsoft Office\Office14\EXCEL.EXE
    --- Un journal des erreurs détaillé suit. 
    
    === Informations d'état de liaison préalable ===
    JRN : utilisateur = 7SP1CLEAN\Administrateur
    JRN : DisplayName = Sage Reports Extra Addin, Version=0.0.0.84, Culture=neutral, processorArchitecture=MSIL
     (Partial)
    JRN : Appbase = file:///C:/Program Files/Sage/Sage Reports Extra
    JRN : PrivatePath initial = NULL
    Assembly appelant : (Unknown).
    ===
    JRN : cette liaison démarre dans le contexte de chargement de default.
    JRN : aucun fichier de configuration de l'application n'a été trouvé.
    JRN : utilisation du fichier de configuration de l'ordinateur à partir de C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
    JRN : stratégie non appliquée à la référence à ce stade (liaison d'assembly privée, personnalisée, partielle ou basée sur l'emplacement).
    JRN : tentative de téléchargement de la nouvelle URL file:///C:/Program Files/Sage/Sage Reports Extra/Sage Reports Extra Addin.DLL.
    ERR : impossible de terminer l'installation de l'assembly (hr = 0x8013101b). Détection terminée.
    
       --- Fin de la trace de la pile d'exception interne ---
    
    
    ************** Assemblys chargés **************
    mscorlib
        Version de l'assembly : 2.0.0.0
        Version Win32 : 2.0.50727.5448 (Win7SP1GDR.050727-5400)
        CodeBase : file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
    ----------------------------------------
    Microsoft.VisualStudio.Tools.Office.Runtime.v10.0
        Version de l'assembly : 10.0.0.0
        Version Win32 : 10.0.31119.0
        CodeBase : file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Office.Runtime.v10.0/10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Office.Runtime.v10.0.dll
    ----------------------------------------
    System
        Version de l'assembly : 2.0.0.0
        Version Win32 : 2.0.50727.5453 (Win7SP1GDR.050727-5400)
        CodeBase : file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------
    System.Core
        Version de l'assembly : 3.5.0.0
        Version Win32 : 3.5.30729.5420 built by: Win7SP1
        CodeBase : file:///C:/Windows/assembly/GAC_MSIL/System.Core/3.5.0.0__b77a5c561934e089/System.Core.dll
    ----------------------------------------
    Microsoft.VisualStudio.Tools.Applications.Hosting.v10.0
        Version de l'assembly : 10.0.0.0
        Version Win32 : 10.0.31119.0
        CodeBase : file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Hosting.v10.0/10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.Hosting.v10.0.dll
    ----------------------------------------
    System.AddIn
        Version de l'assembly : 3.5.0.0
        Version Win32 : 3.5.30729.5420 built by: Win7SP1
        CodeBase : file:///C:/Windows/assembly/GAC_MSIL/System.AddIn/3.5.0.0__b77a5c561934e089/System.AddIn.dll
    ----------------------------------------
    Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0
        Version de l'assembly : 10.0.0.0
        Version Win32 : 10.0.31119.0
        CodeBase : file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0/10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll
    ----------------------------------------
    Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0
        Version de l'assembly : 9.0.0.0
        Version Win32 : 9.0.30729.4130
        CodeBase : file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0/9.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll
    ----------------------------------------
    mscorlib.resources
        Version de l'assembly : 2.0.0.0
        Version Win32 : 2.0.50727.5448 (Win7SP1GDR.050727-5400)
        CodeBase : file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
    ----------------------------------------
    Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.resources
        Version de l'assembly : 9.0.0.0
        Version Win32 : 9.0.30729.4130
        CodeBase : file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.resources/9.0.0.0_fr_b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.resources.dll
    ----------------------------------------
    Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.resources
        Version de l'assembly : 10.0.0.0
        Version Win32 : 10.0.21022.1
        CodeBase : file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.resources/10.0.0.0_fr_b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.resources.dll
    ----------------------------------------

    It seems that the assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. 

    So, Do you think That I should make Excel loads the right runtime to be able to load the add in? if yes, How this can be done without influencing other add in that uses older version of the runtime? If No, what else can I try?

    "Sorry for the french text. Let me now if you have problem getting understand the text writen in french."

    Thanks in advance.


    said

    Wednesday, October 28, 2015 10:58 AM

All replies

  • Hi said,

    Could you reproduce that issue with a new project?

    What’s the result if you try it in other machine?

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, October 29, 2015 6:12 AM
  • Hi Starain,

    I have created a new add-in project for Excel 2010 based on .NET 4. I deployed it using Windows Installer following this post: https://msdn.microsoft.com/en-us/vsto/ff937654.aspx. After finishing the installation of the setup, the add-in apperaed in Excel of the same machine.

    I tried to install the setup in other machine but this time the add-in didn't appear in Excel.

    Idd an additional point, I checked the files contained in the installation directories of the main project and the new project to compare office extensions dlls. they shares only Microsoft.Office.Tools.Common.v4.0.Utilities. I can see the following difference between the two dlls:



    said

    Thursday, October 29, 2015 2:19 PM
  • Hi,

    Please try to re-install VS2010 tools for office runtime and check the result.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, October 30, 2015 1:32 AM
  • Hi, 

    I have repaired and re-installed VS 2010 Tools for Office Runtime, generated a new build but I get always the same Exception at the opening moment of Excel.

    But according to the text exception "System.BadImageFormatException: This assembly is built by a runtime newer than the currently loaded" I thought to make Excel use the right runtime to load the assembly. So I updated my App.config file since it wasn't done automatically: 

    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    </startup>

    I also update office extentions in installation directory.

    Now, at the startup of Excel, I can see the add-in being loaded "Loading [my] Addin" and  the exception above no longer appears. But the Ribbon's Add-in didn't appear on Excel.

    I checked under Excel ==> File ==> Options ==>Add-ins. I can see the add-in as active:

     Also, the add-in is not disabled and everything on the registry seem to be good.

    So, Is this a compatibility issue between Execl 2010 and .NET 4 Framework?

    Regards 


    said

    Friday, October 30, 2015 2:11 PM
  • Hello Said,

    Do you get any UI errors? See How to: Show Add-in User Interface Errors for more information.

    Anyway, take a look at the Migrating Office Solutions to the .NET Framework 4 or later page which describes all the required steps for migrating Office add-in projects to the .net 4.0 runtime. 

    Pay special attention to the Updating Ribbon Customizations in Office Projects that You Migrate to the .NET Framework 4 or the .NET Framework 4.5 page. If the target framework of your project is changed to the .NET Framework 4 or later, you must change the generated code for the Ribbon item by performing the steps described in the article.

    Friday, October 30, 2015 9:10 PM
  • Hi,

    I'm trying to involve some senior engineers into this issue and it will take some time. Your patience will be greatly appreciated.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, November 2, 2015 2:10 AM
  • Many thanks Starain.

    Regards.


    said

    Monday, November 2, 2015 9:05 AM
  • Hello Eugene;

    I have enabled Add-in User Interface Errors in Excel and I get this: 

    I am working on it. However, if you have an idea it will be appreciated.

    Please let me know if you have problem understanding the french text.

    thanks in advance.


    said

    Monday, November 2, 2015 10:52 AM
  • Hello Said,

    What Ribbon XML markup do you use?

    Monday, November 2, 2015 12:09 PM