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?
 
Renat Tlebaldziyeu


Guest


Hi Søren,

Please try to make your thread as ApartmentState.STA before starting:
ThreadStart sendTask = new ThreadStart(transport.Send);
Thread thread = new Thread(sendTask);
thread.SetApartmentState(ApartmentState.STA)
thread.Start();

Does it fix the second issue?
Posted 29 Feb, 2012 02:14:25 Top
Søren Hjarlvig




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

Thank you for the suggestion. Unfortunately, I get keep getting the same 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)

I wonder if the error is related to this:

http://stackoverflow.com/questions/1233468/unable-to-cast-com-object-of-type-exception

Best regards
Posted 29 Feb, 2012 14:09:54 Top
Renat Tlebaldziyeu


Guest


Thank you, Søren.

In this case, I think you should create a Security Manager instance in the same thread. Please try to create the second instance of Security Manager in the DoneHandler. Here is the code:
public void DoneHandler(...)
{
try {
SecurityManager securityManager2 = new SecurityManager(); 
securityManager2.DisableOOMWarnings = true;
...
} finally {
securityManager2.DisableOOMWarnings = false;
}

Did it help?
Posted 01 Mar, 2012 01:37:31 Top
Søren Hjarlvig




Posts: 34
Joined: 2007-02-22
Sorry, no. Even if I create a new instance as you suggest I get the same error :-(

Soeren
Posted 01 Mar, 2012 17:00:37 Top
Renat Tlebaldziyeu


Guest


Hi Søren,

Thank you for testing this.
Could you please send me a sample project, which reproduces the issue (please see readme.txt for the support e-mail address and make sure your e-mail contains a link to this topic)?
Posted 02 Mar, 2012 02:24:21 Top
Andrei Smolin


Add-in Express team


Posts: 18218
Joined: 2006-05-11
Hi Søren,

Thank you for sending us the project. Please pay attention that you deploy Security Manager via MSI while the article describes deploying it via ClickOnce: Outlook Security Manager 2010 deployment: Reg Free COM & ClickOnce for Outlook 2010 64-bit, part 5.

This makes the difference. When using a .MSI installer, you must register Security Manager with administrative permissions as described in the Delpoyment section in the manual, see {Add-in Express}\Docs\osm.pdf on your PC (strongly recommended). In your project, you deploy a per-user add-in; a standard user running your installer will be unable to register Security Manager because of the lack of appropriate permissions.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 05 Mar, 2012 01:26:35 Top
Søren Hjarlvig




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

But I thought the new version of OSM could run WITHOUT registrationen?
And indeed it can, but not if you use it from a new thread (as demonstrated in the project I sent).
Anyway, I have found a work-around, so I don't need the Security Manager in the new thread. So no stress ;)

Regards

Soeren
Posted 05 Mar, 2012 01:31:00 Top
Andrei Smolin


Add-in Express team


Posts: 18218
Joined: 2006-05-11
Hi Søren,

Security Manager must be registered before you use it.

As to using threads in a COM add-in, please check On using threads in managed Office extensions. The blog describes many problems caused by using Office object models in a thread other than the main one.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 05 Mar, 2012 02:17:03 Top