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 
Bob Rowe


Guest


I am using version 7 of Outlook Security Manager. I have followed the directions of the article "How To Deploy Outlook Security Manager with Clickonce using Reg Free Com".

However, I cannot get it to work without manually registering the secman.dll ... I have over 300 installations and cannot go from machine to machine.

I can get the program deployed, but get an error on this line of code. Any Help?

Dim OutlookApp As Microsoft.Office.Interop.Outlook.Application = Nothing
Dim NewMail As Outlook.MailItem = Nothing
Dim OlType As Type = Type.GetTypeFromProgID("Outlook.Application", False)
Dim SecurityManager1 As New AddinExpress.Outlook.SecurityManager

If Not (OlType Is Nothing) Then
Dim CanQuit As Boolean = True

Try
OutlookApp = Marshal.GetActiveObject("Outlook.Application")
If Not (OutlookApp Is Nothing) Then
CanQuit = False
End If
Catch
End Try

Try
If (OutlookApp Is Nothing) Then
OutlookApp = Activator.CreateInstance(OlType)
End If
Catch

End Try

SecurityManager1.ConnectTo(OutlookApp) <----------Error Here
SecurityManager1.DisableOOMWarnings = True


Any suggestions? What is simpler what to grab the existing instance of Outlook?
Posted 12 Feb, 2013 16:29:21 Top
Andrei Smolin


Add-in Express team


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

I would add some logging to the Catch blocks in your code to find out the actual error message.

I suppose the issue is this. A program run via "Run as administrator" cannot communicate with another program run in the usual way if UAC is turned ON.


Andrei Smolin
Add-in Express Team Leader
Posted 13 Feb, 2013 00:53:40 Top
Bob Rowe


Guest


The Error is an HRESULT E_FAIL...

If I manually register the secman.dll, I can get it to work. Are you saying that UAC must be turned off, for Reg Free COM to work? I have 300 installs in 4 states that I cannot get to each machine. So, I am motivated to get this to work.

Also, do you have template VB.NET code on the proper way to access a running instance of Outlook? I have checked the HOW TO section of your site and there are some 404 errors.
Posted 13 Feb, 2013 09:39:16 Top
Andrei Smolin


Add-in Express team


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

I don't think the problem is in your code; it looks correct for me. But your code doesn't report the error message which might tell us more about the real cause ot the issue.

Bob Rowe writes:
If I manually register the secman.dll, I can get it to work.


Great! That is the problem might be caused by secman.dll not registered on an earlier stage.

Bob Rowe writes:
Are you saying that UAC must be turned off


Never in my life. I said that if one program is run via "Run as administrator" then another program will not be able to communicate with it. For instance, if Outlook is run via "Run as administrator" and your program not. These are speculations, however, the error message should shed light on this.

Bob Rowe writes:
Also, do you have template VB.NET code on the proper way to access a running instance of Outlook


We don't have it. These are Microsoft articles on this:

- http://support.microsoft.com/kb/316126 (you can use an online CSharp to VB.NET code converter if required)

- http://support.microsoft.com/kb/308409


Andrei Smolin
Add-in Express Team Leader
Posted 14 Feb, 2013 01:02:28 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
And please copy here the details on the exception you are currently getting.


Andrei Smolin
Add-in Express Team Leader
Posted 14 Feb, 2013 01:03:42 Top
Bob Rowe


Guest


Here is the full error info:

System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component. at AddinExpress.Outlook.IOutlookSecurityManager2.Check(Int32 apiType) at AddinExpress.Outlook.SecurityManager.set_DisableOOMWarnings(Boolean value) at Em.frmCassi.cmdPreview_Click(Object eventSender, EventArgs eventArgs)

Error HRESULT E_FAIL has been returned from a call to a COM component.

Thanks for your help in getting this resolved.
Posted 14 Feb, 2013 17:33:27 Top
Andrei Smolin


Add-in Express team


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

0x8000400 is about wrong permissions.

Please describe how your program is started.

And please check if Marshal.GetActiveObject("Outlook.Application") produces an exception. You can just comment out the corresponding Try/Catch block.


Andrei Smolin
Add-in Express Team Leader
Posted 15 Feb, 2013 02:27:14 Top
Bob Rowe


Guest


It is a standard winforms application deployed with ClickOnce. The application is started via the desktop icon/application reference. There are no special start up options/procedures. There is always a valid Outlook profile on the users machine (mostly Windows 7). Any suggestions.
Posted 15 Feb, 2013 08:28:57 Top
Andrei Smolin


Add-in Express team


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

Can you please comment out all Try/Catch blocks in your code and tell me what code line produces an exception? And please provide more info about it. Is this possible?


Andrei Smolin
Add-in Express Team Leader
Posted 15 Feb, 2013 09:03:46 Top
Bob Rowe


Guest


With the Catch/Try lines disabled, I get the error on the .disableoomwarnings line (see below).


If Not (OlType Is Nothing) Then
Dim CanQuit As Boolean = True

OutlookApp = Marshal.GetActiveObject("Outlook.Application")
If Not (OutlookApp Is Nothing) Then
CanQuit = False
End If

If (OutlookApp Is Nothing) Then
OutlookApp = Activator.CreateInstance(OlType)
End If


SecurityManager1.ConnectTo(OutlookApp)
SecurityManager1.DisableOOMWarnings = True <----------Error Here

Error Message: System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component. at AddinExpress.Outlook.IOutlookSecurityManager2.Check(Int32 apiType) at AddinExpress.Outlook.SecurityManager.set_DisableOOMWarnings(Boolean value) at Em.frmCassi.cmdPreview_Click(Object eventSender, EventArgs eventArgs)
Posted 15 Feb, 2013 09:44:57 Top