Outlook Security Manager Reg Free COM not working?

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

Outlook Security Manager Reg Free COM not working?
 
Søren Hjarlvig




Posts: 34
Joined: 2007-02-22
Hi,

I have followed your guide at
http://www.add-in-express.com/creating-addins-blog/2010/03/02/outlook-clickonce-regfreecom-deployment/
but it doesn't really seem to work.

I'm using OSM (6.0.3015.2005) from within a ADX Outlook add-in and I keep getting the following error:

Assembly Full Name: AddinExpress.MSO.2005, Version=6.2.3051.2005, Culture=neutral, PublicKeyToken=4416dd98f0861965
Assembly Version: 6.2.3051.2005

Exception Source: SecurityManager.2005
Exception Type: System.ApplicationException
Exception Message: The 'secman.OutlookSecurityManager' COM object is not registered.
Exception Target Site: set_DisableOOMWarnings

---- Stack Trace ----
AddinExpress.Outlook.SecurityManager.set_DisableOOMWarnings(value As Boolean)


The manifest file is named "Native.bwoutlook.manifest" (my add-in is called bwoutlook). Is this correct?
The MS documents you reference mention that it should be named after the assembly?

Manifest file contents:

<?xml version="1.0" encoding="utf-8"?>
<assembly xsi:schemaLocation="urn:s chemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv1="urn:s chemas-microsoft-com:asm.v1" xmlns:asmv2="urn:s chemas-microsoft-com:asm.v2" xmlns:asmv3="urn:s chemas-microsoft-com:asm.v3" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:co.v1="urn:s chemas-microsoft-com:clickonce.v1" xmlns:co.v2="urn:s chemas-microsoft-com:clickonce.v2" xmlns="urn:s chemas-microsoft-com:asm.v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity name="Native.bwoutlook" version="1.0.4425.28165" type="win32" />
<file name="secman.dll" asmv2:size="144664">
<hash xmlns="urn:s chemas-microsoft-com:asm.v2">
<dsig:Transforms>
<dsig:Transform Algorithm="urn:s chemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<dsig:DigestValue>yMAcYzaunJiAO5Fd2aV36LhmbsY=</dsig:DigestValue>
</hash>
<typelib tlbid="{11549fe4-7c5a-4c17-9fc3-56fc5162a994}" version="1.0" helpdir="" resourceid="0" flags="HASDISKIMAGE" />
<comClass clsid="{826d7151-8d99-434b-8540-082b8c2ae556}" threadingModel="Apartment" tlbid="{11549fe4-7c5a-4c17-9fc3-56fc5162a994}" progid="secman.OutlookSecurityManager.1" description="OutlookSecurityManager Class" />
</file>
</assembly>

I hope you can help.

Best regards

Soeren
Posted 13 Feb, 2012 17:10:03 Top
Renat Tlebaldziyeu


Add-in Express team


Posts: 132
Joined: 2010-02-15
Hi Søren,

It looks like you use an old build of Outlook Security Manager 2010.
I recommend you to install the latest version of Security Manager (6.2.3017), you can download it from our web-site. Here is the download page:
http://www.add-in-express.com/downloads/osm.php

Please note that if you deploy an ADX-based add-in via ClickOnce with Add-in Express 2010 for Office and .net, you needn’t register dlls manually.
If you have a SecurityManager.2005.dll reference in your project, then after selecting "Publish ADX Project" from the Build menu and clicking the Populate button in the “Publish” dialog window, you will see that the secman.dll and secman64.dll files were added automatically to the Files list for publishing. They will also get registered automatically when your add-in is installed on the end-user PC. It’s a feature of Add-in Express 2010.

Did it help?
Posted 14 Feb, 2012 03:08:03 Top
Søren Hjarlvig




Posts: 34
Joined: 2007-02-22
I have now upgraded to the latest version of Outlook Security Manager, but unfortunately the problem remains.
I'm deploying using a MSI-package generated by Visual Studio 2010.
Until now I have registrered secman.dll using a custom installer action, but some of our customers are using other add-ins which are also using Outlook Security Manager.
In order to avoid version conflicts I would like to switch to reg free com. According to http://msdn.microsoft.com/en-us/magazine/cc188708.aspx (and your own blog) this should be possible by generating an application manifest. I'm just not sure of the correct filename of the manifest file?

Regards

Søren
Posted 14 Feb, 2012 16:08:11 Top
Renat Tlebaldziyeu


Add-in Express team


Posts: 132
Joined: 2010-02-15
Hi Søren,

Thank you for the update.
You can find the detailed instructions on how to deploy Security Manager using Reg Free COM & ClickOnce in the following article on our technical blog:
http://www.add-in-express.com/creating-addins-blog/2010/06/04/outlook-deployment-clickonce/

Could you please try to create a setup project following the steps described in this article?
Posted 15 Feb, 2012 01:33:30 Top
Søren Hjarlvig




Posts: 34
Joined: 2007-02-22
Hi again,

Thank you for your response.
The problem is that I'm not deploying a standalone application but an Add-In Express add-in.
So I dont't know which manifest-file to modify.
I assume it is not "adxloader.dll.manifest" ?

Soeren
Posted 15 Feb, 2012 15:28:26 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Søren,

Please take a look at the Outlook Security Manager 2010 deployment: Reg Free COM & ClickOnce for Outlook 2010 64-bit, part 5 article on our technical blog. It described the required steps.
.NET, Extended MAPI, Windows Phone & RT
Posted 16 Feb, 2012 06:44:58 Top
Renat Tlebaldziyeu


Add-in Express team


Posts: 132
Joined: 2010-02-15
Hi Søren,

I'm sorry. I think I got a little confused,could you please specify if you deploy your project via ClickOnce or if you use Visual Studio setup project?

You can also try using Outlook Security Manager without registration, it’s a new feature introduced in the latest build of Security Manager 2010 (2010.6.1.3017). You can download it from our web-site. Here is the download page:
http://www.add-in-express.com/downloads/osm.php

To deploy your project without registering Security Manager dlls, please execute the following steps:
1. Include the SecurityManager.2005.dll assembly in your setup package. This assembly should be placed into a folder where all your deployed assemblies are located.
2. Include two redistributable libraries – secman.dll and secman64.dll – put them either into the shared folder of Windows, “[Common Files Folder]\Outlook Security Manager” or into your application folder.
3. That’s all. You don’t need to register any dlls.
Posted 17 Feb, 2012 03:44:27 Top
Søren Hjarlvig




Posts: 34
Joined: 2007-02-22
Hi

Thank you for helping me out.

I have tried using the latest version (6.2.3017) with mixed results:

If secman.dll is placed in the application folder I still get the "The 'secman.OutlookSecurityManager' COM object is not registered" error, however, if I copy secman.dll to the "[Common Files Folder]\Outlook Security Manager"-folder (still without registering) it works!

It also works if I copy secman.dll to the assembly cache folder where SecurityManager.2005.DLL resides
(Application Data\assembly\dl3\ZPKV56XM.N45\E9ETTMPX.7PM\7e2c0b65\00b5c0fb_60ebcc01).

BUT (in both cases) if I spawn a new thread and then executes "securityManager.DisableOOMWarnings = true;" in the new thread I get the following error:

System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'AddinExpress.Outlook.IOutlookSecurityManager2'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{66EEF543-A9AC-4A9D-AA3C-1ED148AC8FFE}' failed due to the following error: En sådan grænseflade understøttes ikke (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
at AddinExpress.Outlook.IOutlookSecurityManager2.Check(Int32 apiType)
at AddinExpress.Outlook.SecurityManager.set_DisableOOMWarnings(Boolean value)
at bwoutlook.ItemSendHandler.BluewhaleDoneHandler(Object trans, SendResult sendResult)
at bwbackend.Transport.Send()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Best regards

Soeren
Posted 25 Feb, 2012 11:01:50 Top
Renat Tlebaldziyeu


Add-in Express team


Posts: 132
Joined: 2010-02-15
Hi Søren,

As you develop an Add-in Express based add-in, you should know about the ShadowCopyEnabled property.

When Security Manager is being initialized it tries to find secman.dll or secman64.dll in the folder in which your assembly is loaded.
If the ShadowCopyEnabled property is enabled for your add-in, Security Manager will try to find the dlls in the cache folder (not in your add-in application folder) but will not find it. So, you should set the ShadowCopyEnabled property to false for your add-in loader or copy the dlls into the add-in's cache folder into which your assembly is loaded before creating an instance of Security Manager.

You can find more info in the "Deploying add-ins - shadow copy" tip:
http://www.add-in-express.com/docs/net-deploying-debugging-tips.php#Shadow%20copy
You can find the ShadowCopyEnabled property in the adxloader.dll.manifest in the sources of your add-in.

Could you please show me the full code you use (you can remove all business logic)?
Posted 27 Feb, 2012 01:35:39 Top
Søren Hjarlvig




Posts: 34
Joined: 2007-02-22
Changing shadowCopy to false solved the first problem! :-)

But I still get the "System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'AddinExpress.Outlook.IOutlookSecurityManager2'." error.

Some code is something like this:

public class AddinModule : ADXAddinModule
{
private ADXOutlookAppEvents adxOutlookEvents;

public AddinModule()
{
...
this.adxOutlookEvents.ItemSend += new ADXOlItemSend_EventHandler(adxOutlookEvents_ItemSend);
}

private void adxOutlookEvents_ItemSend(object sender, ADXOlItemSendEventArgs e)
{
new ItemSendHandler(this).ItemSend(e);
}
}

public class ItemSendHandler
{
private SecurityManager securityManager;

public void ItemSend(ADXOlItemSendEventArgs args)
{
try {
securityManager = new SecurityManager();
securityManager.DisableOOMWarnings = true; // works!
...

Progress progress = new Progress(...);
progress.OnDone += this.DoneHandler;
progress.Start();
} finally {
securityManager.DisableOOMWarnings = false; // works!
}
}

public void DoneHandler(...)
{
try {
securityManager.DisableOOMWarnings = true; // System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'AddinExpress.Outlook.IOutlookSecurityManager2'.
...
} finally {
securityManager.DisableOOMWarnings = false;
}
}
}

// Nb. Progress and Transport is located in another assembly

public class Progress
{
public void Start()
{
ThreadStart sendTask = new ThreadStart(transport.Send);
Thread thread = new Thread(sendTask);
thread.Start();
}
}

public class Transport
{
public event doneHandler OnDone;

public void Send()
{
...
OnDone(..); // Notifies DoneHandler in ItemSend
}

}
Posted 29 Feb, 2012 01:50:58 Top