Security Manager COM Error

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

Security Manager COM Error
Security Manager COM Error 
Andrei Smolin


Add-in Express team


Posts: 14094
Joined: 2006-05-11
Hi Bob,

I've added secman.dll to my project as described in that blog and got a problem: my project stopped installing. I removed secman.dll and it started working. I suggested that you remove secman.dll and use my project as a sample. We will look into the article. It looks like a fix is required.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 21 Feb, 2013 09:59:49 Top
Bob Rowe




Posts: 17
Joined: 2010-10-29
Thanks - keep me posted.
Posted 21 Feb, 2013 11:01:39 Top
Andrei Smolin


Add-in Express team


Posts: 14094
Joined: 2006-05-11
Hello Bob,

We've deleted the original article which you refered to. It was found that the article is deprecated and it cannot be used now. Please refer to this article instead: Outlook Security Manager 2010 deployment: Reg Free COM & ClickOnce for Outlook 2010 64-bit, part 5.

I'm terribly sorry for the incovinience that this may have caused you.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 02 Mar, 2013 07:10:02 Top
Bob Rowe




Posts: 17
Joined: 2010-10-29
This article discusses how to register the Secman64.dll.

I am more interested in deploying the 32-bit secman.dll via ClickOnce without manually registering it.

Can this be done?
Posted 04 Mar, 2013 14:49:54 Top
Andrei Smolin


Add-in Express team


Posts: 14094
Joined: 2006-05-11
Bob,

In fact, the article discusses the use of a correct DLL (secman.dll or secman64.dll) depending on the bitness of the target, not how to register secman64.dll. The sample project I sent you earlier demonstrates what the article describes: it deploys secman.dll and secman64.dll using ClickOnce and it does NOT register the DLLs.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 05 Mar, 2013 05:09:01 Top
Bob Rowe




Posts: 17
Joined: 2010-10-29
I am getting the error "Application Identity not Set" on the line of code -> ManifestFixProc.Start

Also in the project publish properties should the CoreFlags.exe and ManifestFix.exe be set to "Copy to Output: Always"
Posted 05 Mar, 2013 13:08:14 Top
Bob Rowe




Posts: 17
Joined: 2010-10-29
Should the CoreFlags.exe be copied over to the install directory on the client machine? I have tried about every combination of things. I have followed the "Outlook Security Manager 2010 deployment: Reg Free COM & ClickOnce for Outlook 2010 64-bit, part 5. " and cannot get this to work. I get the E_Fail Error every time.


If I am only deploying to 32-bit version of Outlook, then do I need the latest version of Security Manager (2005)? Can I just use the older version and/or deploy secman.dll?

Thanks.
Posted 05 Mar, 2013 16:20:38 Top
Andrei Smolin


Add-in Express team


Posts: 14094
Joined: 2006-05-11
Bob,

To walk you through all this stuff, I’ve recreated the test project, which I sent to you earlier. And now I will try to outline all the steps.

1. I have Windows 64bit. I've created a standalone app that automates Outlook 2013 32 bit. This is a Windows Forms app with just one button. In the Click event of the button, a new Outlook.Application object is created and the sender name of the first email from the Inbox folder is shown:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim OutlookApp As Outlook.Application = New Outlook.Application()
        Dim Session As Outlook.NameSpace = OutlookApp.Session
        Dim Inbox As Outlook.MAPIFolder = _
            Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
        Dim mail As Outlook.MailItem = Inbox.Items.GetFirst()

        SecurityManager1.ConnectTo(OutlookApp)
        SecurityManager1.DisableOOMWarnings = True

        Try
            MessageBox.Show(mail.SenderName)
        Catch ex As Exception
            MessageBox.Show("Exception: " + ex.Message)
        Finally
            SecurityManager1.DisableOOMWarnings = False
            SecurityManager1.Disconnect(OutlookApp)
        End Try
    End Sub


On my PC where Security Manager is installed, the application works correctly.

2. I copied the following files to the project folder and added them to the project; all of them have Build Action = Content (see the Properties window):
- secman.dll
- secman64.dll
- CorFlags.exe
- ManifestFix.exe

3. I added the following code to the Load event of the form:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Debug.Print("!!! IsNetworkDeployed = " + System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed.ToString())
        If System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed Then
            Debug.Print("!!! IsFirstRun = " + System.Deployment.Application.ApplicationDeployment.CurrentDeployment.IsFirstRun.ToString())
        End If
        Try
            If (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed And System.Deployment.Application.ApplicationDeployment.CurrentDeployment.IsFirstRun) Then
                Debug.Print("!!! Form1_Load. IsNetworkDeployed is true, IsFirstRun is true")
                Dim ManifestFixPath As String = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ManifestFix.exe")
                Dim ManifestFixProc As Process = Nothing
                Try
                    ManifestFixProc = New Process()
                    ManifestFixProc.StartInfo.FileName = """" + ManifestFixPath + """"
                    ManifestFixProc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
                    ManifestFixProc.StartInfo.Arguments = Process.GetCurrentProcess().Id.ToString() + " """ + Assembly.GetExecutingAssembly().Location + """"
                    Debug.Print("!!! Form1_Load. Starting the process")
                    ManifestFixProc.Start()
                    Debug.Print("!!! Form1_Load. Killing the process")
                    Process.GetCurrentProcess().Kill()
                Catch ex As Exception
                    Debug.Print("!!! Form1_Load. Exception: " + ex.Message)
                End Try
            End If
        Catch
        End Try
    End Sub


4. I set CopyLocal=true for SecurityManager.2005 in the References section of the project properties. Then I made a copy of Security Manager's files (just a precaution) and uninstalled Security Manager. To verify that Security Manager is uninstalled completely, I ran the app - it produced an exception "The 'secman64.OutlookSecurityManager64' COM object is not registered." which means that Security Manager’s files weren't registered on my PC.
5. I published the application to a file-system location; this created a temporary .PFX and added it to the project.
6. I double-clicked the {application name}.application file, this started the installer. After the installation, the application started and its form was displayed. The application works as expected: clicking the button shows the sender's name of the first email in my Inbox with no exceptions or security warnings.

If you have problems with this, I'm ready to access your PC remotely. If this is possible, I would suggest using TeamViewer; in this case you will need to send me your session ID and password (by email, please).

Note that building and publishing are different things. You need to publish your project after you build a new app version.

Bob Rowe writes:
Also in the project publish properties should the CoreFlags.exe and ManifestFix.exe be set to "Copy to Output: Always"


This property adds the file to the bin folder. But this isn't required for publishing the file.

Bob Rowe writes:
Should the CoreFlags.exe be copied over to the install directory on the client machine?


The files to be delivered to the client are listed here:
{project} | Properties | the Publish tab | the Application Files button.

For my test project I have these files:

User added an image
The actual location of these files is determined by ClickOnce.

Bob Rowe writes:
If I am only deploying to 32-bit version of Outlook, then do I need the latest version of Security Manager (2005)? Can I just use the older version and/or deploy secman.dll?


How old is the version that you are going to use?

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 06 Mar, 2013 09:32:59 Top
Bob Rowe




Posts: 17
Joined: 2010-10-29
I believe part of the problem may be that the CorFlags.exe is not being copied over into the install directory (If that is where it supposed to go). CorFlags.exe is in the Published Directory.

I have verified that my settings match yours above. Can you help me address this issue?
Posted 06 Mar, 2013 14:03:37 Top
Bob Rowe




Posts: 17
Joined: 2010-10-29
I have CorFlags worked out...

The Line ManifestFixProc.Start() throws the Error:

System.Deployment.Application.InvalidDeploymnetException: Application Identity is not set. at

System.Deployment.ApplicationDeployment.get_CurrentDeployment()

"Application Identity Not Set"

It appears as if the ManFix process is not running which is why I still get the error in the application.

Any ideas on this?

Thanks for the help.
Posted 06 Mar, 2013 14:34:25 Top