locked
VSTO Addin Outlook 2007 not loaded after installation RRS feed

  • Question

  •  

    Hi,

    I developed an addin for outlook 2007 with VSTO and Visual Studio 2005. For correct deploying I read the papers "Deploying Visual Studio 2005 Tools for Office SE Solutions using Windows Installer" part 1 and 2. After some time everything seems to work fine. But finally I noticed, that my addin wasn't loaded in Outlook 2007 after installation.

     

    It is displayed in Outlook 2007 (Com-)Addin list but when I check its box to activate it nothing happens. When I return to the (Com-)Addin list the box is unchecked again.  What could be the problem that it isn't loaded while starting up Outlook? Is there something like an Outlook logfile where I can check what happens while trying to load my addin?

     

    Thankx.

     

    Friday, July 27, 2007 11:13 AM

Answers

  • Hi !

     

    I tried to implement the SetSecurity project in my own project... but it failed... so I've looked for some more simple solution to bypass the windows CAS and give enought security-level to my addin.

     

    I found this post http://weblogs.asp.net/mnissen/archive/2005/07/01/417148.aspx on the Madsn's blog. It describes a one part Installer class which gives FullTrust permission to the assembly. The post is pretty old but it works for me under OL2007 and Vista.

     

    I hope it will help...

     

     

    Romain Vailleux

    Tuesday, July 31, 2007 9:15 AM

All replies

  •  

    Hello Martinez,

     

    Try to set the environment variable VSTO_SUPPRESSDISPLAYALERTS to 0.

     

    Visual Studio Tools for Office can write all errors that occur during startup to a log file or display each error in a message box. By default, these options are turned off for Outlook projects. You can turn the options on by adding and setting environment variables. To display each error in a message box, set the VSTO_SUPPRESSDISPLAYALERTS variable to 0 (zero). You can suppress the messages by setting the variable to 1 (one). To write the errors to a log file, set the VSTO_LOGALERTS variable to 1 (one). Visual Studio Tools for Office creates the log file in the folder that contains the application manifest. The default name is <Manifestname>.manifest.log. To stop logging errors, set the variable to 0 (zero). For information about setting environment variables in Microsoft Windows XP, see "How To Manage Environment Variables in Windows XP" (http://support.microsoft.com/default.aspx?scid=kb;en-us;310519).

     

    Then look at the Logfile and see what's causing the problem.

     

    Also I would recommend to create some logfiles from your application.

    I do it usually with Trace statements.

    You can see a sample on my site http://www.x4u.de/Programming/Outlook/Codesnippets/tabid/61/Default.aspx

    Have a look at the Trace and Log sample.

     

    Hope this helps,

    greets, Helmut

    Friday, July 27, 2007 9:26 PM
    Answerer
  • Have you confirmed the Addin Registry entry is in the Current User Key, does the HKCU\Software\Microsoft\Office\Outlook\Addins\youraddin.connect\LoadBehavior = 3 after outlook has loaded or is it placed back as 2.

     

    Another error could be the Addin is black listed - go into Outlook select Tools and Trust Center then select addins and check not listed in the Disabled Application Addin List.

     

    Can you confirm all of the component and dependant DLL's are included in your security policy in .NET configuration you should be able to see if you expand the configuration to check that Full Permission has been granted to all of your assemblies.

     

    Regards

     

     

    Friday, July 27, 2007 9:39 PM
  • OK, I check things out. But what I already noticed is that theres no logfile written and no error message displayed although I have set the enviroment variable "VSTO_..." mentioned above. What could be the reason for that?

    Monday, July 30, 2007 1:17 PM
  • Have you check the Office Resiliency keys?  Check to see if  you have any entrys in the Registry under HK Current User \ Software \ Microsoft \ Office\ 12.0 \Word \ Resliency .  If office has disabled your addin in this way, you won't see any Errors from your Addin because the VSTO Runtime never gets called.

     

    Kris

     

    Tuesday, July 31, 2007 12:30 AM
    Answerer
  • Hi !

     

    I tried to implement the SetSecurity project in my own project... but it failed... so I've looked for some more simple solution to bypass the windows CAS and give enought security-level to my addin.

     

    I found this post http://weblogs.asp.net/mnissen/archive/2005/07/01/417148.aspx on the Madsn's blog. It describes a one part Installer class which gives FullTrust permission to the assembly. The post is pretty old but it works for me under OL2007 and Vista.

     

    I hope it will help...

     

     

    Romain Vailleux

    Tuesday, July 31, 2007 9:15 AM
  • Thank you for your response.
    After changing the SetSecurity Project according to the
    http://weblogs.asp.net/mnissen/archive/2005/07/01/417148.aspx post parts of my addin appear in Outlook-Surface. I can see my custom menu there. Unfortunately the addin isn't still loaded correctly. I can't execute the functions that my Outlook-Menu contains. Checking out the state of my addin in Outlook it still says that it is inactive. The loadBehaviour in the registry changes from 3 to 2 after Outlook each startup.

    What I still can't explain myself is that there's no logfile written although setting the enviromentvariable "VSTO_SUPPRESSDISPLAYALERTS = 1".

    Are there any other ways to check whar happens while the addin is loaded?


    Here's the code that code of the SetSecurity : Installer class that seems to work better than that in the Deploying visual studio example:

    [RunInstaller(true)]
        [System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
        public sealed partial class SetSecurity : Installer
        {
            public SetSecurity()
            {
                InitializeComponent();
            }

            public override void Install(System.Collections.IDictionary stateSaver)
            {
                base.Install(stateSaver);
                try
                {
                    //System.Windows.Forms.MessageBox.Show("Da simma dabei...");
                    // Find the machine policy level
                    System.Security.Policy.PolicyLevel machinePolicyLevel = null;
                    System.Collections.IEnumerator policyHierarchy = SecurityManager.PolicyHierarchy();

                    while (policyHierarchy.MoveNext())
                    {
                        PolicyLevel level = (PolicyLevel)policyHierarchy.Current;
                        if (level.Label == "Machine")
                        {
                            machinePolicyLevel = level;
                            break;
                        }
                    }

                    if (machinePolicyLevel == null)
                    {
                        throw new ApplicationException(
                            "Could not find Machine Policy level. Code Access Security " +
                            "is not configured for this application."
                            );
                    }

                    // Create a new FullTrust permission set
                    PermissionSet permissionSet = new NamedPermissionSet("FullTrust");

                    // Get the install directory of the current installer
                    string assemblyPath = this.Context.Parameters["assemblypath"];
                    string installDirectory = assemblyPath.Substring(0, assemblyPath.LastIndexOf("\\"));

                    if (!installDirectory.EndsWith(@"\"))
                        installDirectory += @"\";

                    installDirectory += "*";
                    IMembershipCondition membershipCondition = new UrlMembershipCondition(installDirectory);

                    // Create the code group
                    PolicyStatement policyStatement = new PolicyStatement(permissionSet);
                    CodeGroup codeGroup = new UnionCodeGroup(membershipCondition, policyStatement);
                    codeGroup.Description = "VSTO Permissions for Objectware AS Plugins";
                    codeGroup.Name = "Objectware AS";

                    // Add the code group
                    machinePolicyLevel.RootCodeGroup.AddChild(codeGroup);

                    // Save changes
                    SecurityManager.SavePolicy();
                }

                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.ToString());
                }
            }

    ...
    Tuesday, July 31, 2007 3:00 PM