title: VSTO 3.0 outlook addin does not load
body: <p>I have written a VSTO 3.0 add in for outlook. It is on the usual lines of ThisAddIn. The addin is targeted at office 2007 or above. We discovered recently that it does not work on certain workstations. Here is a summary of where it fails to load.</p>
  
  <p>The addin loads and works fine on:
  1) All 32-bit workstations (both windows server 2003 and windows 7) with Office 2007
  2) All 32-bit workstations (both windows server 2003 and windows 7) with Office 2010</p>
  
  <p>The addin does not even load on certain 64-bit workstations. We have compared the workstations where it works and where it doesn't. They are exactly the same, including the set of software installed. In fact, we spent a lot of time ensuring that both are the same in all respects. </p>
  
  <p>They are both 64-bit workstations running Windows server 2003, Office 2007 (32-bit). I have figured so far that Office 2007 does not have a 64-bit version. The exact error that i receive in the event log is:
  Please note that i have removed the URL (VSTO URL) from this post.</p>
  
  <blockquote>
    <p>Customization URI: "VSTO URL" Exception: Customization could not be
    loaded because the application domain could not be created.
    <strong><em>*</em>**<em>*</em>**</strong> Exception Text <strong><em>*</em>**<em>*</em>**</strong> Microsoft.VisualStudio.Tools.Applications.Runtime.CannotCreateCustomizationDomainException:
    Customization could not be loaded because the application domain could
    not be created. ---> System.IO.FileLoadException: Loading this
    assembly would produce a different grant set from other instances.
    (Exception from HRESULT: 0x80131401)    at
    System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean
    publicOnly, Boolean noCheck, Boolean&amp; canBeCached,
    RuntimeMethodHandle&amp; ctor, Boolean&amp; bNeedSecurityCheck)    at
    System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean
    fillCache)    at System.RuntimeType.CreateInstanceImpl(Boolean
    publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)    at
    System.Activator.CreateInstance(Type type, Boolean nonPublic)    at
    System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder
    binder, Object[] args, CultureInfo culture, Object[]
    activationAttributes)    at System.Activator.CreateInstance(Type type,
    BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo
    culture, Object[] activationAttributes)    at
    System.Activator.CreateInstance(String assemblyName, String typeName,
    Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[]
    args, CultureInfo culture, Object[] activationAttributes, Evidence
    securityInfo, StackCrawlMark&amp; stackMark)    at
    System.Activator.CreateInstance(String assemblyName, String typeName) 
    at System.AppDomain.CreateInstance(String assemblyName, String
    typeName)    at System.AppDomain.CreateInstanceAndUnwrap(String
    assemblyName, String typeName)    at
    System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String
    typeName)    at
    Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.LoadMafPipeline(AppDomain
    newDomain, IntPtr hostServiceProvider, AddInInformation info,
    EntryPoints requestedEntryPoints, OfficeApp officeApplication,
    OfficeVersion officeVersion, IntPtr&amp; executor)    at
    Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.CreateCustomizationDomainInternal(String
    solutionLocation, String manifestName, String documentName, Boolean
    showUIDuringDeployment, IntPtr hostServiceProvider, IntPtr&amp; executor) 
    --- End of inner exception stack trace ---</p>
    
    <p><em><strong></em>**<em>*</em>**<em></strong> Loaded Assemblies <strong></em>**<em>*</em>****</strong> mscorlib
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.5737 (QFE.050727-5700)
        CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
    ---------------------------------------- Microsoft.VisualStudio.Tools.Office.Runtime.v10.0
        Assembly Version: 10.0.0.0
        Win32 Version: 10.0.21022.1</p>
    
    <h2>    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</h2>
  </blockquote>
  
  <p>I have figured out that my  addin is failing to load if another addin built on similar lines gets loaded first. This addin, say, Adddin1 if loads renders my addin inactive. Addin1 is built similar to my addin- same target environment. If i disable Addin1 my addin loads fine. I do not have the liberty to change anything on Addin1 due to various reasons. <br/>What changes can i make on my addin to load independently of any other addin? <br/>
  Can i choose the order in which addins are loaded? <br/>
  Is there any dependency on vstoee.dll?</p>
  
  <p>Any suggestions would help. Thank you.</p>