Problem with installation and secman.dll

Add-in Express™ Support Service
That's what is more important than anything else

Problem with installation and secman.dll
 
Mikael Rosvall




Posts: 3
Joined: 2006-05-12
I'm developing and Outlook add-in (Office 2003) that reads distribution lists from the Outlook address book using Visual Studio 2005, C# and Visual Studio Tools for Office (VSTO). To avoid the security warning I used Outlook Security Manager. When in debug mode the solutions works fine, but when I install the add-in on other computers the reading of the address book doesn't work anymore (the app doesn't crash but all the code that comes after the line that switches of the security is not executed). I have followed the instructions on how to include the secman.dll file in the installation, but it still doesn't work!

Here what I did to include the secman.dll file:

1) The secman.dll file is installed under Common Files Folder\Outlook Security Manager.
2) Under properties I set the Registry value to "vsdrfCOMSelfReg" and Permanent to true.


Here's the code that reads the address book:


private AddinExpress.Outlook.SecurityManager SecurityManager;

private void readDistributionListsInAddressbook()
        {
            try
            {
                //get addresslist path
                Outlook.Application myApp = new Outlook.Application();
                Outlook._NameSpace myOutlookNamespace = myApp.GetNamespace("MAPI");
                Outlook.MAPIFolder myContactsFolder = myOutlookNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);

                //Disable the security warning
                this.SecurityManager = new AddinExpress.Outlook.SecurityManager();
                SecurityManager.DisableOOMWarnings = true;

                foreach (object item in myContactsFolder.Items)
                {
                    if (item is Outlook.DistListItem)
                    {
                        Outlook.DistListItem list = (Outlook.DistListItem)item;

                        for (int i = 0; i <= list.MemberCount; i++)
                        {
                            string name = null;
                            string phoneNo = null;

                            Outlook.Recipient recipient = list.GetMember(i);
                            if (recipient != null)
                            {
                                string email = recipient.Address;

                                object o = myContactsFolder.Items.Find("[Email1Address] = '" + email + "'");
                                if (o is Outlook.ContactItem)
                                {
                                    name = ((Outlook.ContactItem)o).FullName;
                                    phoneNo = ((Outlook.ContactItem)o).MobileTelephoneNumber;
                                    try
                                    {
                                        //Add the items to a data table.
                                    }
                                    catch
                                    { }
                                }
                            }
                        }
                    }
                }

            }
            finally
            {
                //Re-enable the security warning
                SecurityManager.DisableOOMWarnings = false;
            }
        }


Does anyone have any idea what's wrong?
Posted 12 May, 2006 15:51:56 Top
Sergey Grischenko


Add-in Express team


Posts: 7235
Joined: 2004-07-05
Hi Mikael.

Could you please add the catch statement in the code?
In this case we will see what exception occurs.
Posted 15 May, 2006 05:09:19 Top
Mikael Rosvall




Posts: 3
Joined: 2006-05-12
The thing is that I don't get any exception even with a catch statement (I've tried adding a catch); the code just stops executing any method that comes after the "readDistributionListsInAddressbook"-method. As I said before the app doesn't even crash or stop working, it just “gives up” when the following line is executed:


this.SecurityManager = new AddinExpress.Outlook.SecurityManager();


I'm starting to suspect that the secman.dll file is not trusted by Outlook as COM-object. Could this be the case, and if so: how do I fix it in the installer?
Posted 15 May, 2006 06:51:23 Top
Sergey Grischenko


Add-in Express team


Posts: 7235
Joined: 2004-07-05
Mikael, I will test SecurityManager component in the VSTO project and will let you know about results ASAP.
Posted 15 May, 2006 10:31:19 Top
Sergey Grischenko


Add-in Express team


Posts: 7235
Joined: 2004-07-05
Hi Mikael.

I got the same issue on my PC but the installation of the SecurityManager.2005.dll assembly to the GAC solved the problem.
Another solution is to grant trust to the SecurityManager.2005.dll assembly using the Caspol.exe tool. In this case the assembly can be located in the same folder with the add-in dll.
Posted 15 May, 2006 19:23:40 Top
Mikael Rosvall




Posts: 3
Joined: 2006-05-12
Adding the SecurityManager.2005.dll to the CAG solved the problem.

Thank you very much Sergey :D
Posted 16 May, 2006 04:30:33 Top