AcquireLicense Error

Discussions related to order tracking development with the ProForm module.

Moderator: Phil Barton

Post Reply
manjunath.bhat
Posts: 7
Joined: Wed Mar 08, 2017 4:01 am

AcquireLicense Error

Post by manjunath.bhat » Thu Apr 19, 2018 8:08 am

Hello!

We are trying to Read/Edit SoftPro orders from SDK (4.3.50811.25). Here is the code sample that is throwing an error "AcquireLicense"

Code: Select all

public class Server
    {
        private static SelectServer oSelectServer;
        private Server()
        {}

        private static void Initialize()
        {
            oSelectServer = new SelectServer(new Uri(Config.SelectServerURI), Credentials());
        }

        public static SelectServer Start()
        {
            string reason;
            if (oSelectServer == null || oSelectServer.ConnectionState != ConnectionState.Open)
                Initialize();

            if (oSelectServer.TryAuthenticate(out reason))
                oSelectServer.EnsureAuthenticated();
            else
                throw new Exception(reason);

            return oSelectServer;
        }
        public static bool End()
        {
            if (oSelectServer.ConnectionState == ConnectionState.Open)
                oSelectServer.Dispose();
            return true;
        }

        private static NetworkCredential Credentials()
        {
            return new NetworkCredential(Config.UserName, Config.Password, Config.Domain);
        }

        public static IOrderStore SearchOrder(string OrderNumber, SelectServer oSelectServer, ref IOrder Order, OrderEditMode EditMode)
        {
            IOrderStore oOrderStore = oSelectServer.GetService<IOrderStore>();
            IOrderInfo oSearch = oOrderStore.Orders.Where(t => t.Number == OrderNumber).FirstOrDefault();
            Order = oOrderStore.OpenOrder(oSearch, EditMode);
            return oOrderStore;
        }
    }

Code: Select all

		SelectServer oSelectServer = Server.Start();
           	IOrder Order = null;
		Try{
                                IOrderStore oOrderStore = Server.SearchOrder(OrderNumber, oSelectServer, ref Order, OrderEditMode.ReadOnly); 
                           	// OR OrderEditMode.ReadWrite based on the need
                                /*Business logic goes here*/

				oOrderStore.ApplyChanges(Order); // If order was opened in ReadWrite mode
                                 oOrderStore.CloseOrder(Order);
			}
		catch (Exception Ex) {
			// Log Exception
			}

		finally
                {
                                Server.End();
                }       
Exception thrown when multiple users on website trying to connect to SoftPro, opening different orders using the same SoftPro account.

System.NullReferenceException: Object reference not set to an instance of an object. at SoftPro.Select.Client.SelectServerObject.AcquireLicense(LicensedProduct product) at SoftPro.OrderTracking.Client.Orders.OrderStore.SoftPro.OrderTracking.Client.Orders.IOrderStore.CloseOrder(IOrder order) at Module.SoftProClient.Business.ClosingStatement.Get() at Module.AppEngine.Applications.TIPro.Controls.ClosingStatement.ClosingStatementXpress.OrderSelected(Object sender, EventArgs e) at Fnf.NetSolutions.Website.Applications.DocPrepXpress.Controls.Common.Orders.ddlOrders_SelectedIndexChanged(Object sender, EventArgs e) at Fnf.NetSolutions.Website.Applications.DocPrepXpress.Controls.Common.Orders.Page_Load(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint

Please let me know if you have any idea on the error.

Thanks,
Manjunath

BobRichards
Posts: 1007
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: AcquireLicense Error

Post by BobRichards » Thu Apr 19, 2018 10:55 am

It appears that you ran out of licenses.

TryAuthenticate() returns true if the credentials are recognized by the Select mid-tier as a valid user. It does not say anything about the availability of licenses since different users may be interested in different products (ProClear, ProForm, ProTrust, etc.). It is only when one of your users accesses the OrderStore and gets an order (creates, whatever), that a "ProForm" license is consumed. You need to either add code to your singleton to limit the number of users with OrderStore access or get more licenses.
Bob Richards, Software Developer, SoftPro

Post Reply