Tuesday, April 26, 2016

CRM XRM service including error information

Here is what you need to add to the web.config of the CRM website so that you can see why the XRM service maybe failing on a call:

<system.serviceModel>

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

     <behaviors>

      <serviceBehaviors>

        <behavior>

          <serviceDebug includeExceptionDetailInFaults="true" />

        </behavior>

      </serviceBehaviors>

    </behaviors>

  </system.serviceModel>

Friday, April 15, 2016

RegionManager.RequestNavigate is not working!

This is not so much a solution, but a debugging hint.

Recently I was banging my head for hours on a RequestNavigate not working. After a lot of googling and head banging, I found out that RequestNavigate has a callback and it has useful error information that can help in determining the issue.

The signature is: public static void RequestNavigate(this IRegionManager regionManager, string regionName, Uri source, Action navigationCallback)

And here is how you can use it:

_regionManager.RequestNavigate(RegionNames.MainRegion, uri, nr =>
{
if (nr.Result.HasValue && nr.Result == false)
{
//put a breakpoint in here to determine why. nr.Error will have the data
var error = nr.Error;
}
});

In my case, I found out that the caller was on a background thread and hence, the navigation was failing silently. By subscribing to my event on the UI thread, I was able to solve my issue!