I have a silverlight app embedded in an IFRAME in Dynamics CRM... calls after the form is loaded retrieve data via the CRM service soap client. The client is programmatically initialized with the URL and the CRM authentication token injected into the headers.
All of this, by itself, works perfectly fine.
The problem came in when I added a "loading..." animation. To display the animation correctly, I've marshalled the service requests onto a background thread, essentially replacing...
QuestionContext.RetrieveOptions();
... with ...
ThreadPool.QueueUserWorkItem(delegate {
QuestionContext.RetrieveOptions();
});
The moment I do this, though, I (somewhat sporadically) get a credentials prompt. Cancelling the prompt results in a "Not Found" error by the web service.
I've placed clientaccesspolicy.xml in the CRMWeb root, my ISV site root, as well as the ClientBin folder where my .xap is located... none of them are making a difference.
UPDATE: Providing valid credentials in the prompt has no effect, the prompt re-appears 3 times and then we're back to the "Not Found" error.
UPDATE: I've wrapped the service call responses with some error checking, each time on the "Not Found" error simply re-issuing the request. Now, pressing cancel in the credentials prompt whenever it is presented eventually results in satisfied requests. That is, it doesn't consistently fail, and re-issuing the request an unspecified number of times eventually results in success.
I've also added a Thread.Sleep() in before my Execute() call to the soap client in an effort to see if the calls were somehow interfering with one another, but it hasn't seemed to make a difference.