Skip to main content

Microsoft Silverlight

Answered Question Exception in calling service during application_exitRSS Feed

(0)

codism
codism

Member

Member

372 points

121 Posts

Exception in calling service during application_exit

Hi, I am calling a WCF method to save user's change in the current "page" in Application_Exit method. An exception occurs:

An exception of type 'System.NullReferenceException' occurred in System.ServiceModel.dll but was not handled in user code
Additional information: Object reference not set to an instance of an object.

inside the "Reference.cs":

System.IAsyncResult _result = base.BeginInvoke("SaveClientList", _args, callback, asyncState);

I have a simple navigation framework in my application and the current "page" does no difference between navigation to another page and closing of the IE window. The exception appears to me like the asynchronous call needs some object that was released due to the closing of IE window. Can any one confirm me if this is a bug in Silverlight or I did something wrong?

Thanks in advance. 

jackbond
jackbond

Contributor

Contributor

2820 points

725 Posts

Answered Question

Re: Exception in calling service during application_exit

As web service calls are all async now, there's no clean way to specify, "don't close until this service call has completed". Your options are:

Use the XmlHttpWrapper to make the call sync (doesn't work on older browsers that do not support xmlhttp)

Try putting the thread to sleep for x amount of time (Truly ugly, and just how long should x be?)

 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities