Getting Started with OL Security Manager

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

Getting Started with OL Security Manager
Registering assemblies and components 
Kevin Yurica


Guest



I'm just getting started with OL Security Mgr- so I may be missing the obvious. Anyway, the following approach (creating 'outlookApp') and adding it to my main 'Connect' object seems to compile fine, but generates a rather general error message. "Object Reference not set to an instance of the object"

One guess is that .dll registration could have something to do with it, since I haven't made any effort to register secman.dll. But, that's just a naive guess.

ApplicationClass outlookApp = new ApplicationClass();
Type olType = Type.GetTypeFromProgID("EmailApplication.Connect", false);
if (olType != null)
{
bool canQuit = true;
try
{
if (outlookApp != null) canQuit = false;
}
catch
{
}
try
{
if (outlookApp != null)
{
securityManager1.ConnectTo(outlookApp);
securityManager1.DisableOOMWarnings = true;
}
}
catch(System.Exception err)
{
}
etc.
Posted 29 Aug, 2005 14:27:56 Top
Sergey Grischenko


Add-in Express team


Posts: 7202
Joined: 2004-07-05
Hi Kevin.

Could you please try the following code to create an instance of Outlook application:

Outlook._Application outlookApp = null;
Type olType = Type.GetTypeFromProgID("Outlook.Application", false);
if (olType != null)
{
try
{
outlookApp = Activator.CreateInstance(olType) as Outlook._Application;
.......
}
finally
{
if (outlookApp != null)
Marshal.ReleaseComObject(outlookApp);
}
}

Do you get the same issue?
Posted 30 Aug, 2005 01:11:21 Top
Kevin Yurica


Guest


Sergey:

Thanks for the suggestion. It appears an instance can be created. But, the following statements fail subsequently. Makes me wonder about how I have setup securityManager1...

try
{
outlookApp = Activator.CreateInstance(olType) as Outlook._Application;
"OK seems to work- no errors so far.."

this.securityManager1.ConnectTo(outlookApp);
"Error - Object reference ot set to an instance of the object"

this.securityManager1.DisableOOMWarnings = true;
"Never makes it this far.."
}
}
Posted 30 Aug, 2005 12:35:49 Top
Kevin Yurica


Guest


Error message should have read..

"Error - Object reference not set to an instance of the object"
Posted 30 Aug, 2005 12:43:24 Top
Kevin Yurica


Guest



At last, some success! The following code executes fine if it's located in a form that is not contained by the 'Connect' object. When the same code is located within the 'Connect' object it doesn't want to run for some reason. I thought maybe using the Connect Obj ProgID (say: EmailApp.Connect) would help, but no real luck. It isn't throwing an exception either...just not suppressing the OL security warning when something is accessed.

Outlook._Application outlookApp = null;
Type olType = Type.GetTypeFromProgID("Outlook.Application", false);
try
{
outlookApp = Marshal.GetActiveObject("Outlook.Application") as Outlook._Application;
}
catch
{
}
try
{if (outlookApp == null)
outlookApp = Activator.CreateInstance(olType) as Outlook._Application;
}
catch
{
}
if (outlookApp != null)
{
securityManager1.DisableOOMWarnings = true;
}
etc.
Posted 30 Aug, 2005 19:58:22 Top
Sergey Grischenko


Add-in Express team


Posts: 7202
Joined: 2004-07-05
Hi Kevin.

Could you send me the project. I will try to help.
Posted 31 Aug, 2005 11:01:29 Top
Guest


Guest



Sergey:

Thanks for the help- but I may be out of the woods on this one.

In short, my connect.cs file contains both static and instanced methods. Calls to securityManager1 appear to work fine from instanced methods, but fail from static methods. This makes sense given the way I've instantiated securityManager in the 'OnStartupComplete' stage of the connection process.

I noticed your Add-in Express product seems to dramatically simplify the connection object landscape for your users- which is great. For better or worse I've slogged around with the MS native connection infrastructure for so many months that I guess I'll just hack it into submission this time. But, next time I'll try Add-in Express..
Posted 31 Aug, 2005 17:51:20 Top
Sergey Grischenko


Add-in Express team


Posts: 7202
Joined: 2004-07-05
Kevin, is it possible for you to refuse calls to Security Manager from static methods?
If not, then I will try to investigate this issue.
Posted 31 Aug, 2005 19:35:33 Top
Kevin Yurica


Guest



Sergey:

I am still trying to characterize the circumstances under which I can reach an instance Security Manager from within my connection object. So far from any static method, I get the error previously noted (Object reference not set to an instance of the object). From an instanced method it seems I can reach the Security Manager under most circumstances.

You asked if it was possible to refuse calls from static methods....hmmm....not sure yet....good question. Let me see what else I can figure out. I suppose I should be using the 'osmResult Check' function to help diagnose?
Posted 01 Sep, 2005 13:07:17 Top
Sergey Grischenko


Add-in Express team


Posts: 7202
Joined: 2004-07-05
I suppose I should be using the 'osmResult Check' function to help diagnose?


I don't think so. You told me that you got the error message in the ConnectTo method. The point is that, you can use the 'osmResult Check' function after the ConnectTo method has been called.

Kevin, can I look at the code of your connection module? Probably you could send me the project where the error message takes place.
Posted 01 Sep, 2005 18:22:33 Top