Monday, 23 July 2012

An unexpected error occurred. (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault).

In my previous post, I described how to import a solution programmatically, one thing I did not do was show how I instantiated the OrganizationServiceProxy nor how I had configured the Application Pools for the MS Dynamics website.

This is the method I used to instantiate the OrganizationServiceProxy:
 private OrganizationServiceProxy InstantiateOrgService(OrganizationServiceProxy service, string OrgName, string FQDN, int port = 80, int TimeOut = 600)
 {
     try
     {
         ClientCredentials creds = new ClientCredentials();
         creds.Windows.ClientCredential = (NetworkCredential)CredentialCache.DefaultCredentials;
 
         service = new OrganizationServiceProxy(new Uri(string.Format(Constants.OrgURL, FQDN, port, OrgName)), null, creds, null);
         service.Timeout = new TimeSpan(0, 0, TimeOut);
 
         return service;
     }
     catch (Exception ex)
     {
         MessageBox.Show(string.Format("Unable to instatiate the Org Service. Exception {0}", ex));
 
         return null;
     }
 }
I had another method that I had used where I passed in an specific set of credentials, rather than using default credentials, and that method had worked fine, but when I changed to the method above, it would not work and I would get this rather helpful message:
An unexpected error occurred.
(Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault).
After a lot of hair pulling and useless Google searches (sorry my esteemed friend) I realized what I had changed, I was using Default Credentials, but the Application pool was not configured to use a domain account, so I changed the account running the CRM Application Pool to a domain account and this resolved the issue:


4 comments:

  1. i am getting an 'unexpected error' with
    ImportSolutionRequest, but it looks like for a different reason.

    posted on MSDN forums http://social.microsoft.com/Forums/en/crmdevelopment/thread/eea92469-bb72-496a-9912-acc274810e5b

    So far have not seen anyone else run into this.

    ReplyDelete
    Replies
    1. anything showing up in the logs?

      Using libraries from different versions is a bad idea but should not cause the issue, in theory. Not sure whether anything has actually changed around this on the latest libraries

      Delete
  2. im having the same problem... but i can not do that change in the application pool, there is any other way to fix the problem..?, please somebody help me with this.

    ReplyDelete
    Replies
    1. have you tried explicitly passing the credentials you want to use?

      Delete