A few months ago, our developing server started to show some asp net errors while trying to open a custom query, while charging a list of workflows associated to an entity, publishing customizations, etc… I modified the web.config to show the trace and the result is always the same: Cannot cast a System.String[] to System.String.

Looking for similar errors in the community, I tried some solutions, like increment the timeouts to connect the DB in the registry and the web config, but don’t fix the problem.

Recently, we had another problem, while trying to delete custom attributes from the entities, we got the classical error from CRM, not an unhandled exception, but looking at the traces in log files, the problem start with a date time format error (despite of we have the same date format in CRM, application server, database server and client machines, Spanish), but ends with the invalid cast error. Here is the trace:

·         [2011-11-17 11:18:15.6] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread:   11 |Category: Exception |User: 00000000-0000-0000-0000-000000000000 |Level: Error | CrmException..ctor
 at CrmException..ctor(String message, Int32 errorCode)
 at CrmDateTime.Deserialize(String serializedForm, String formattedDate, String formattedTime)
 at ConvertHelper.FromXmlString(AttributeMetadata attributeMetadata, String xmlString)
 at SerializableHelper.ConditionOperatorReader(XmlNode node, ConditionExpression condition)
 at DeserializeFetchVisitor.Visit(FilterExpression criteria)
 at DeserializeFetchVisitor.Visit(EntityExpression entity)
 at EntityExpression.DeserializeFromFetchXml(String xmlInfo)
 at ViewUsageHelper.CheckFetch(String fetchXml, Boolean isSpecialView, EntityMetadata entityMD, Guid entityId, ExecutionContext context)
 at ViewUsageHelper.CheckViews(BusinessEntityCollection entities, ExecutionContext context)
 at UsageHelper.CheckSystemViews(Guid entityId, Guid attributeId, DynamicMetadataCache mdCache, ExecutionContext context)
 at UsageHelper.GetAttributeUsageInfo(Guid attributeId, Guid relationshipId, DynamicMetadataCache mdCache, ExecutionContext context)
 at AttributeService.GetUsageInfo(Guid attributeId, ExecutionContext context)
 at AttributeService.GetUsageInfo(Guid attributeId)
 at AttributeDelete.Execute(IUser user, Guid attributeId)
 at SystemCustomization.DeleteAttribute(Guid attributeId)
 at RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
 at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
 at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
 at LogicalMethodInfo.Invoke(Object target, Object[] values)
 at WebServiceHandler.Invoke()
 at WebServiceHandler.CoreProcessRequest()
 at SyncSessionlessHandler.ProcessRequest(HttpContext context)
 at CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
 at HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
 at ApplicationStepManager.ResumeSteps(Exception error)
 at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
 at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
 at HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)
 at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
>Crm Exception: Message: The date-time format for jueves, 17 de noviembre de 2011 is invalid, or value is outside the supported range., ErrorCode: -2147220935
[2011-11-17 11:18:15.6] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread:   11 |Category: Platform |User: 00000000-0000-0000-0000-000000000000 |Level: Error | MiniDump.CreateDumpInternal
>Exception while loading mini-dump settings:
System.InvalidCastException: No se puede convertir un objeto de tipo 'System.String[]' al tipo 'System.String'.
   en Microsoft.Crm.MiniDump.MiniDumpSettings.Create()
[2011-11-17 11:18:15.6] Process: w3wp |Organization:959ad491-713e-e011-a7e9-1c6f6593341d |Thread:   11 |Category: Platform.Metadata |User: 00000000-0000-0000-0000-000000000000 |Level: Error | AttributeService.GetUsageInfo
>AttributeService.GetUsageInfo caught exception: System.InvalidCastException: No se puede convertir un objeto de tipo 'System.String[]' al tipo 'System.String'.
   en Microsoft.Crm.MiniDump.MiniDumpSettings.Create()
   en Microsoft.Crm.MiniDump.CreateDumpInternal(MiniDumpReasons reason, Exception exception)
   en Microsoft.Crm.MiniDump.CreateDump(MiniDumpReasons reason, Exception exception)
   en Microsoft.Crm.CrmException..ctor(String message, Exception innerException, Int32 errorCode, Boolean isFlowControlException, Boolean enableTrace)
   en Microsoft.Crm.CrmException..ctor(String message, Int32 errorCode)
   en Microsoft.Crm.BusinessEntities.CrmDateTime.Deserialize(String serializedForm, String formattedDate, String formattedTime)
   en Microsoft.Crm.Platform.ConvertHelper.FromXmlString(AttributeMetadata attributeMetadata, String xmlString)
   en Microsoft.Crm.Query.SerializableHelper.ConditionOperatorReader(XmlNode node, ConditionExpression condition)
   en Microsoft.Crm.Query.DeserializeFetchVisitor.Visit(FilterExpression criteria)
   en Microsoft.Crm.Query.DeserializeFetchVisitor.Visit(EntityExpression entity)
   en Microsoft.Crm.Query.EntityExpression.DeserializeFromFetchXml(String xmlInfo)
   en Microsoft.Crm.Metadata.ViewUsageHelper.CheckFetch(String fetchXml, Boolean isSpecialView, EntityMetadata entityMD, Guid entityId, ExecutionContext context)
   en Microsoft.Crm.Metadata.ViewUsageHelper.CheckViews(BusinessEntityCollection entities, ExecutionContext context)
   en Microsoft.Crm.Metadata.UsageHelper.CheckSystemViews(Guid entityId, Guid attributeId, DynamicMetadataCache mdCache, ExecutionContext context)
   en Microsoft.Crm.Metadata.UsageHelper.GetAttributeUsageInfo(Guid attributeId, Guid relationshipId, DynamicMetadataCache mdCache, ExecutionContext context)
   en Microsoft.Crm.Metadata.AttributeService.GetUsageInfo(Guid attributeId, ExecutionContext context)

We can't also create new custom entities, or import from other enviroments.

Any idea? We work with CRM 4.0, Windows Server 2007 and sql server 2005 in the same machine.

Thanks.