Object reference not set to an instance of an object. Creating dynamic application

Dec 17, 2014 at 4:44 AM
Hi,

I am trying to close a existing a application and trying create it again.

The application is global.
if (this.desktopAccess.AppExistsInUI("Traffic"))
{
this.desktopAccess.CloseDynamicApplication("Traffic");
}
Context newCtx = new Context(this.Context.GetContext());
// Change it

newCtx["username"] = trafficUsername.ToString();
newCtx["password"] = trafficPassword.ToString();
// Raise the update
FireChangeContext(new ContextEventArgs(newCtx));

this.desktopAccess.CreateDynamicApplication("Traffic");
FireRequestAction(new RequestActionEventArgs("Traffic", "TrafficApp", customData));
But i am getting the below error
System.NullReferenceException was unhandled by user code
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=Microsoft.Uii.Csr.Core
StackTrace:
   at Microsoft.Uii.Csr.HostedWebApplication.DoDefaultAction()
   at Microsoft.Uii.Csr.ApplicationHost.ExecuteDefaultActions(IHostedApplication app)
   at Microsoft.Crm.UnifiedServiceDesk.Services.UsdDesktopBase.CreateDynamicApplication(String applicationName)
   at SearchControl.USDControl.DoAction(RequestActionEventArgs args)
   at Microsoft.Uii.Csr.Aif.HostedApplication.HostedWpfControl.HandleRequestAction(Object sender, RequestActionEventArgs args)
InnerException:

Can anybody have an idea ?