none
VSTO 2005 SE/Outlook 2003 Deployment: OL Add-in Not Loading RRS feed

  • Question

  • I know this is probably the eleventy billionth question about VSTO deployment issues, and I apologize but I can't see what I'm doing incorrectly here.

    I have an Outlook Add-in developed in VS 2008 using VSTO 2005 SE and the Outlook 2003 template, which is deployed via an MSI file. This is currently installing and running fine with Outlook 2007, but Outlook 2003 is proving to be a bear. It is simply not loading at all and being disabled, with the VSTO log not displaying any detail other than the standard "The customization assembly associated with this document could not be loaded...".

    I am using the following Installer class for CASPOL installation:

    namespace CustomSetupActions
    {
      [RunInstaller(true)]
      public partial class CASPolicyInstaller : Installer
      {
        private readonly string installPolicyLevel = "Machine";
        private readonly string namedPermissionSet = "FullTrust";
        private readonly string codeGroupDescription = "VSTO Permissions for MyProduct";
        private readonly string productName = "MyProductName";
    
        private string codeGroupName = String.Empty;
    
        private string CodeGroupName
        {
          get
          {
            if (String.IsNullOrEmpty(codeGroupName))
              codeGroupName = "[" + productName + "] " + InstallDirectory;
            return codeGroupName;
          }
        }
    
        private string InstallDirectory
        {
          get
          {
            string assemblyPath = Context.Parameters["assemblypath"];
            string installDirectory = assemblyPath.Substring(0, assemblyPath.LastIndexOf("\\"));
    
            if (!installDirectory.EndsWith(@"\"))
              installDirectory += @"\";
            installDirectory += "*";
    
            MessageBox.Show("Install Directory: " + installDirectory);
            return installDirectory;
          }
        }
    
    
        public CASPolicyInstaller()
        {
          InitializeComponent();
        }
    
        public override void Install(IDictionary stateSaver)
        {
          //MessageBox.Show("In CASPolicyInstaller");
          base.Install(stateSaver);
    
          try
          {
            ConfigureCodeAccessSecurity();
            Rollback(stateSaver);
          }
          catch (Exception ex)
          {
            MessageBox.Show(ex.ToString());
          }
        }
    
        private void ConfigureCodeAccessSecurity()
        {
          PolicyLevel machinePolicyLevel = GetPolicyLevel();
    
          if (GetCodeGroup(machinePolicyLevel) == null)
          {
            // Create new FullTrust permission set
            PermissionSet permissionSet = new NamedPermissionSet(namedPermissionSet);
            IMembershipCondition membershipCondition =
              new UrlMembershipCondition(InstallDirectory);
    
            // Create code group
            PolicyStatement policyStatement = new PolicyStatement(permissionSet);
            CodeGroup codeGroup = new UnionCodeGroup(membershipCondition, policyStatement);
            codeGroup.Description = codeGroupDescription;
            codeGroup.Name = codeGroupName;
    
            machinePolicyLevel.RootCodeGroup.AddChild(codeGroup);
    
            SecurityManager.SavePolicy();
          }
        }
    
        private PolicyLevel GetPolicyLevel()
        {
          PolicyLevel machinePolicyLevel = null;
    
          // Find machine policy level
          IEnumerator policyHierarchy = SecurityManager.PolicyHierarchy();
          while (policyHierarchy.MoveNext())
          {
            PolicyLevel level = policyHierarchy.Current as PolicyLevel;
            if (level.Label.CompareTo(installPolicyLevel) == 0)
            {
              machinePolicyLevel = level;
              break;
            }
          }
    
          if (machinePolicyLevel == null)
          {
            throw new ApplicationException(
                "Could not find Machine Policy level, CAS not configured");
          }
    
          return machinePolicyLevel;
        }
    
        private CodeGroup GetCodeGroup(PolicyLevel policyLevel)
        {
          foreach (CodeGroup codeGroup in policyLevel.RootCodeGroup.Children)
          {
            if (codeGroup.Name.CompareTo(CodeGroupName) == 0)
              return codeGroup;
          }
    
          return null;
        }
    
        public override void Uninstall(IDictionary savedState)
        {
          base.Uninstall(savedState);
          try
          {
            UninstallCodeAccessSecurity();
          }
          catch (Exception ex)
          {
            MessageBox.Show("Unable to uninstall CAS:\n\n:" + ex.ToString());
          }
        }
    
        private void UninstallCodeAccessSecurity()
        {
          PolicyLevel machinePolicyLevel = GetPolicyLevel();
          CodeGroup codeGroup = GetCodeGroup(machinePolicyLevel);
          if (codeGroup != null)
          {
            machinePolicyLevel.RootCodeGroup.RemoveChild(codeGroup);
    
            SecurityManager.SavePolicy();
          }
        }
      }
    }
    
    

    The assmblypath value is appropriate. I also tried SetSecurity with similar results. The requisite registry entries are created and the VSTO 2005 SE & 2003 PIAs are installed. As a log is the first thing done in my startup, it is obvious the startup is not even getting executed before being disabled. Given the complete dearth of debugging information provided here, I'm unsure of where to go from here.

    Thanks for any help you might be able to provide!

     

    Thursday, March 10, 2011 10:17 PM

All replies

  • Hello,

    Thanks for posting. For this issue, to troubleshoot this issue, please try to use the following blog: http://blogs.msdn.com/b/vsto/archive/2010/06/21/troubleshoot-vsto-add-in-load-failures-navneet-gupta.aspx. It might give you more information about add-in load failure.

    Second, please use SetSecurity project for VSTO SE add-in. For this project, we could download it from this link: Deploying Office Solutions Using Windows Installer Version 3. To deploy a VSTO SE add-in, please refer to these two articles: Part I and Part II.

    Third, we could create a very simple VSTO SE add-in following two articles above about deployment. To installing it in another machine with Office 2007 installed, please see if this issue also happens.

    If you have any concern on this post, just feel free to follow up. Have a nice day.


    Bessie Zhao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, March 11, 2011 7:30 AM
  • Thanks for replying, but I've already been through the whole "follow this step-by-step" process months ago, and I found the above solution that previously worked fine on 2003 and does in fact work on 2007. I checked after install with CasPol and the install directory is in fact listed in the Machine Group for FullTrust for the Url of the install directory. Checking individual DLLs shows they fall under that umbrella policy for the directory.

    So, where it appears (and I'm not a Windows security expert -- or even a WINDOWS expert) that the code access policy for this addin and its DLLs appears correct, I am simply looking for the next step in debugging this problem.

    Friday, March 11, 2011 8:45 PM
  • Hello again Jack,

    Have you followed that blog to troubleshoot this issue: http://blogs.msdn.com/b/haahmadi/archive/2010/05/26/my-vsto-add-in-does-not-load.aspx? It might give you more information about add-in load failure. For this error in the question, please try to search it in VSTO forum, and see if the resources could help you or not.

    From what you side, you have tried to use SetSecurity project from that sample in your VSTO SE add-in. It has the same question as the add-in using the CASPolicyInstaller instead of SetSecurity project. Right? If not, please point me out. If yes, would you mind sharing the simple add-in using SetSecurity project with us? So I could use it to reproduce this issue on my side for further research.

    Is there some other dlls in your VSTO SE add-in? If yes, please see this thread to deploy it: http://social.msdn.microsoft.com/forums/en-US/vsto/thread/cec6abb6-4716-4bde-91f2-25fb68abd54e.

    If this post does not help you, just feel free to follow up. Have a nice day.


    Bessie Zhao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, March 14, 2011 8:38 AM
  • Yes, I've been through the whole process, but I will detail it.

    1. "Make sure your add-in is installed correctly and it is enabled"

    The add-in is in the registry in its appropriate place (HKCU\Software\Microsoft\Office\Outlook\Addins\MyAddinName). Its LoadBehavior gets changed from 3 to 2 on Outlook 2003 startup. Its Manifest is pointing to the CompanyName.MyAddinNameShortVersion.dll.manifest file in the installed directory.

    2. "Check out “COM Add-Ins” dialog in Excel"

    The add-in has been marked as disabled on Startup and exists in the Disabled Items list.

    3. "Find the problem"

    The problem is IT IS NOT GIVING ANY DETAIL OF THE ACTUAL PROBLEM! It simply states that is couldn't load the add-in.

    4. "Hard disabled add-ins"

    It is not hard-disabled.

    OK, moving on. There are multiple DLLs in my add-in, always have been. That's why I went with the Custom Action shown in my first post, as it trusts the entire installed add-in directory (at least that is my understanding), just as the SetSecurity modification in the link you provided does. And again...it did in fact work previously, and it works in 2007. The DLLs are all strong-named and consist of the following:

    CompanyName.ShortAddinName.Utilities.dll - no Office references

    CompanyName.ShortAddinName.Resources.dll - no Office references

    CompanyName.ShortAddinName.OutlookBaseImpl.dll - no Office references

    CompanyName.ShortAddinName.Outlook2003Impl.dll - references Microsoft.Office.Interop.Outlook 11.0.0.0, Office 11.0.0.0

    CompanyName.ShortAddinName.Outlook2003.dll (actual addin) - references Microsoft.Office.Interop.Outlook 11.0.0.0, Office 11.0.0.0, Microsoft.Office.Tools.Common 8.0.0.0, Microsoft.Office.Tools.Outlook 8.0.0.0, Microsoft.VisualStudio.Tool.Applications.Runtime 8.0.0.0, stdole 7.0.3300.0, as well as the previous Outlook2003Impl.dll and OutlookBaseImpl.dll

    CompanyName.ShortName.ConfigUI.dll - no Office references

    CompanyName.ShortName.Helper.dll - no Office references

    I fully realize that the most likely explanation is I've done something incorrectly in my references or something of that sort. I am not a full time Office or even Windows developer, and this is a source of incredible frustration for me.

    Tuesday, March 15, 2011 1:03 PM
  • Hello Jack,

    Would you mind simplifying a project and sharing it with us here. So I could use it on my side for further research. If you have any problem on it, I think I also could create a simple VSTO SE add-in for you, and send it to your for testing.

    Have a nice day.


    Bessie Zhao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, March 16, 2011 8:58 AM
  • I've provided a minimal project here: http://db.tt/cHafvvo which imitates in some ways the architecture of my application, and uses the CA I provided in the first post for full trust of the application's install directory. This addin works, as I suspected it would, on Outlook 2003 (which is the system on which I'm experiencing problems).

    This thread is really all about where to go next when you know the security is working fine, but the add-in fails to load with no detail on the issue from VSTO whatsoever.

    Wednesday, March 16, 2011 8:09 PM
  • Thanks very much for sharing the project with me. I will try to use it on my side for some research. As long as there is some useful information, I will follow up again. Have a nice day. :-) 


    Bessie Zhao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, March 17, 2011 9:45 AM
  • Hello again Jack,

    I have installed this add-in in a machine with Office 2003 installed on my side. I could see this issue loaded successfully. Have you checked if the Prerequisites for this add-in have been installed in the machine with Office 2003: Office 2003 PIA, VSTO SE runtime, .NET Framework 3.5 SP1/2.0?


    Bessie Zhao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, March 22, 2011 9:33 AM