locked
RetrieveEntityResponse : Service.Execute - Unexpected error occured RRS feed

  • Question

  • Hello,

    I have build one solution for enabling the document management and while executing RetrieveEntityRequest, I am receiving below error message with exception.

    System.ServiceModel.FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault> was caught
      _HResult=-2146233087
      _message=An unexpected error occurred.
      HResult=-2146233087
      IsTransient=false
      Message=An unexpected error occurred.
      RemoteStackTrace=
    Server stack trace: 
       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    
    Exception rethrown at [0]: 
    
      Source=mscorlib
      Action=http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/ExecuteOrganizationServiceFaultFault
      StackTrace:
        Server stack trace: 
           at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
           at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
           at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
           at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
        Exception rethrown at [0]: 
           at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
           at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
           at Microsoft.Xrm.Sdk.IOrganizationService.Execute(OrganizationRequest request)
           at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.ExecuteCore(OrganizationRequest request)
           at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.Execute(OrganizationRequest request)
           at DocumentMgtEnable.EnableDocumentManagement.Run() in c:\Users\prashant.bhojani\Documents\Visual Studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs:line 90
      InnerException: 
    

    Below is my code:

     using(OrganizationServiceProxy _serviceProxy = new OrganizationServiceProxy(oUri,null,lclClientCredentials,null))
                        {
    
                        RetrieveEntityRequest entityRequest = new RetrieveEntityRequest
                        {
                            EntityFilters = EntityFilters.Attributes,
                            LogicalName = "contact",
    
                            // Retrieve only the currently published changes, ignoring the changes 
                            // that have not been published.
                            //RetrieveAsIfPublished = false
                        };
                        RetrieveEntityResponse entityResponse = (RetrieveEntityResponse)_serviceProxy.Execute(entityRequest);
                        Console.WriteLine("Retrieved the contact entity.");
    
                        // Get the entity from the response.
                        EntityMetadata contactEntity = entityResponse.EntityMetadata;
    
                        // Enable document management for the retrieved entity.
                        contactEntity.IsDocumentManagementEnabled = true;
    
                        // Create an update request.                    
                        UpdateEntityRequest updateRequest = new UpdateEntityRequest
                        {
                            Entity = contactEntity                        
                        };
                        _serviceProxy.Execute(updateRequest);

    Can anyone please help me here, as I am not getting any clue from exception details.

    Wednesday, April 29, 2015 4:58 AM

Answers

  • Hello Minal,

    Thank you for the response.

    The link which you have provided is for CRM Online. I am using CRM On-premise.

    I tried the same code for CRM online it works well. But it is not working for CRM on-premise.

    Please suggest.

    Thank you,

    Mittal.

    • Marked as answer by MittalPatel Wednesday, April 29, 2015 1:08 PM
    Wednesday, April 29, 2015 9:04 AM

All replies