.Net XI2 SDK - creating IReportEngine takes another licence

Hi, I have .Net web-app that uses the XI2 SDK to export Webi Reports as HTML to the app. We impersonate as the current Active Directory user, which is also mapped as a BO user and log on using secWinAD.

The problem we are having is that a 2nd concurrent license is being taken by each user when we create the IReportEngine instance. When we log off from the session, the 1st license is correctly returned, but the 2nd one is not, meaning we have to wait for it to time out before it can be used again.

Any ideas why? Please see code below with comments describing when the concurrent licenses are taken:

            
WindowsIdentity winId = new WindowsIdentity("USERNAME@DOMAIN");

//Start impersonating.
WindowsImpersonationContext ctx = winId.Impersonate();

//Access resources using the identity of the authenticated user.
//NOTE - 1st License is taken here - CORRECT
EnterpriseSession session = (new SessionMgr()).Logon("", "", "SERVERHOSTNAME", "secWinAD");

// Revert impersonation.
ctx.Undo();
            
ReportEngines reportEngines = new ReportEngines(session.LogonTokenMgr.DefaultToken);

//NOTE - After this line, an additional license is taken - WHY?
IReportEngine boIReportEngine = reportEngines.getService(ReportEngineType.WI_ReportEngine);

IDocumentInstance document = boIReportEngine.OpenDocument(1234);

//... Do some work with the document...

document.CloseDocument();
reportEngines.Close();
session.Logoff(); //NOTE - License taken from new SessionMgr()).Logon(..) code is correctly returned here

//At this point, an orphansed license is left, meaning we lose a user until it times out.

JonoWard (BOB member since 2009-03-30)


document.CloseDocument();
reportEngines.Close(); 

Did you try explicitly closing not only ReportEngines but also ReportEngine and then set to NULL reportEngine and reportEngines ?

Let us know if this changes things


Atul Chowdhury (BOB member since 2003-07-07)

Hi Atul, thanks for the reply. I’ve tried the following piece of clean up code as you suggest:

document.CloseDocument();
document = null;
reportEngines.Close();
boIReportEngine.Close();
reportEngines = null;
boIReportEngine = null;
session.Logoff();
session = null;

But unfortunately the 2nd license is still not returned


JonoWard (BOB member since 2009-03-30)

Instead of using a DefaultToken, try:


new ReportEngines(session.LogonTokenMgr.CreateWCAToken("", 1, -1))

Atul Chowdhury (BOB member since 2003-07-07)

Yes that worked! Only 1 license taken, and then returned correctly at the end. Many thanks for your help Atul!


JonoWard (BOB member since 2009-03-30)

Glad I could help ;>


Atul Chowdhury (BOB member since 2003-07-07)