InvalidCastException: Unable to cast object of type 'Microsoft.Xrm.Sdk.Entity' to type 'Xrm.new_salestransaction.

Pergunta InvalidCastException: Unable to cast object of type 'Microsoft.Xrm.Sdk.Entity' to type 'Xrm.new_salestransaction.

  • sábado, 5 de maio de 2012 01:39
     
     

    Hi there,

    I have the Xrm class in a class library which my plugin project reference. But getting the InvalidCastException: Unable to cast object of type 'Microsoft.Xrm.Sdk.Entity' to type 'Xrm.new_salestransaction. How do I need to do? Thanks

    publicvoidExecute(IServiceProviderserviceProvider)

            {

               

    ITracingServicetracingService =

                    (

    ITracingService)serviceProvider.GetService(typeof(ITracingService));

               

             

                    serviceProvider.GetService(

    typeof(IPluginExecutionContext));

    IPluginExecutionContextcontext = (IPluginExecutionContext)IOrganizationServiceFactoryserviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));

    IOrganizationServiceservice = serviceFactory.CreateOrganizationService(context.UserId);

    varCrmContext = new Xrm.XrmServiceContext(service); 

    var entity = CrmContext.new_salestransaction.Where(o => o.aea_BatchId.Id == batchId).singleorDefault();                      

               

    • Editado SPCRM2011 sábado, 5 de maio de 2012 01:47
    •  

Todas as Respostas