Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

MS CRM 2013 on-premise - c# code - Error "An unexpected error occurred" on retrieve of metadata.

$
0
0

Hi All,

I need an urgent help.

I am working on MS CRM 2013 on-Premise version. I am writing c#code to retrieve metadata of entity and getting error on below color(yellow) line. Please check code and error detail after code -

//Creating connection

Uri sOrganizationuri = new Uri("">xxxxx.com/.../Organization.svc");

ClientCredentials sCredentials = new ClientCredentials();

sCredentials.Windows.ClientCredential = new NetworkCredential("username", "password", "domain");

OrganizationServiceProxy sService = new OrganizationServiceProxy(sOrganizationuri, null, sCredentials, null);

// getting metadata code

RetrieveEntityRequest retrieveEntityRequest = new RetrieveEntityRequest
{
EntityFilters = EntityFilters.All,

LogicalName = "account",

RetrieveAsIfPublished = true
};

RetrieveEntityResponse retrieveAccountEntityResponse = (RetrieveEntityResponse)sService.Execute(retrieveEntityRequest);

EntityMetadata EntityMetaData = retrieveAccountEntityResponse.EntityMetadata;

foreach (object attribute in EntityMetaData.Attributes)
{

AttributeMetadata a = (AttributeMetadata)attribute;
string attributeName = a.LogicalName;

}

}

Detail Error 

The Web Service plug-in failed in OrganizationId: be747ce0-89cd-e911-a301-00155d016b08; SdkMessageProcessingStepId: 38b005c5-b7f8-4c22-97ed-a7abc9c22b6c; EntityName: none; Stage: 30; MessageName: RetrieveEntity; AssemblyName: Microsoft.Crm.Extensibility.InternalOperationPlugin, Microsoft.Crm.ObjectModel, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35; ClassName: Microsoft.Crm.Extensibility.InternalOperationPlugin; Exception: Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Web.Services.Protocols.LogicalMethodInfo.Invoke(Object target, Object[] values)
at Microsoft.Crm.Extensibility.InternalOperationPlugin.Execute(IServiceProvider serviceProvider)
at Microsoft.Crm.Extensibility.V5PluginProxyStep.ExecuteInternal(PipelineExecutionContext context)
at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)
Inner Exception: System.MissingMethodException: Method not found: 'Void Microsoft.Xrm.Sdk.Metadata.EntityMetadata.set_IsStateModelAware(System.Nullable`1<Boolean>)'.
at Microsoft.Crm.Sdk.Metadata.EntityMetadataFactory.FillEntityMetadata(EntityMetadata entityMetadata, MetadataBusinessEntity entity, MetadataLoader loader)
at Microsoft.Crm.Sdk.Metadata.EntityMetadataFactory.CreateEntityMetadata(Guid entityId, String entityName, EntityFilters entityItems, MetadataLoader loader)
at Microsoft.Crm.Sdk.Metadata.MetadataReaderFromDatabase.RetrieveEntity(EntityFilters entityItems, String logicalName, Guid metadataId, Boolean retrieveAsIfPublished, ExecutionContext context)
at Microsoft.Crm.Sdk.Metadata.MetadataServiceProvider.RetrieveEntity(EntityFilters entityItems, String logicalName, Guid metadataId, Boolean retrieveAsIfPublished, ExecutionContext context)
.


Viewing all articles
Browse latest Browse all 79901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>