Answered by:
RetrieveEntityResponse : Service.Execute - Unexpected error occured

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
-
Hi,
The error is thrown for at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
So check the login details and user name and password for this. Examples for correct usage is given in the article attached here.
http://crm2011corner.blogspot.com.au/2012/12/sample-code-crm-using-organization.html
Hope this helps.
-----------------------------------------------------------------------
Minal Dahiya
blog : http://minaldahiya.blogspot.com.au/If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"
Wednesday, April 29, 2015 8:40 AM -
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 -
Hi,
Thanks for clarifying this. Here is code sample for the same:
https://msdn.microsoft.com/en-us/library/hh675404.aspx?f=255&MSPPError=-2147217396
https://rajeevpentyala.wordpress.com/2012/02/26/creating-organizationserviceproxy-in-crm2011/
Hope this helps.
-----------------------------------------------------------------------
Minal Dahiya
blog : http://minaldahiya.blogspot.com.au/If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"
Wednesday, April 29, 2015 10:22 AM