日期:2014-05-18  浏览次数:20969 次

类型“System.DateTime”的对象无法转换为类型“System.String”。
调用微软工作流的一个方法:


  List<string> stateList = dbAccess.GetStateByUser(userId);
  List<string> ownerStateList = dbAccess.GetOwnState();

  //加载持久化的工作流
  foreach (SqlPersistenceWorkflowInstanceDescription desc in WorkflowMgr.CurrentWorkflowRuntime.GetService<SqlWorkflowPersistenceService>().GetAllWorkflows())
  {
// WorkflowInstance workflowInstance = WorkflowMgr.CurrentWorkflowRuntime.GetWorkflow(desc.WorkflowInstanceId);

  //查看当前用户是否有权限处理该状态,如果可以,则加入到用户待处理的列表中
  StateMachineWorkflowInstance smwi = new StateMachineWorkflowInstance(WorkflowMgr.CurrentWorkflowRuntime, desc.WorkflowInstanceId); //就在这里提示,但是这里没有DATETIME型的对象啊,最郁闷的是,我在本机上调试时没问题的,放到服务器上发布就出了问题。
if (stateList.Contains(smwi.CurrentStateName))
  {
  try
  {
  ExpenseData expenseData = dbAccess.GetExpenseDataByInstanceID(smwi.InstanceId);
   

  expenseData.Url = dbAccess.GetUrlbyCurrentState(smwi.CurrentStateName);
  expenseData.Runstate = smwi.CurrentStateName;
   
  if ( expenseData != null )
  {
  expenseDataList.Add(expenseData);
  }
  }

  catch
  { }
  }
  else if (ownerStateList.Contains(smwi.CurrentStateName))
  {
  //需要自己处理的流程
  ExpenseData expenseData = dbAccess.GetExpenseDataByInstanceID(smwi.InstanceId);
  expenseData.Url = dbAccess.GetUrlbyCurrentState(smwi.CurrentStateName);
  expenseData.Runstate = smwi.CurrentStateName;

  if (expenseData.User == userId && expenseData != null )  
  {
  expenseDataList.Add(expenseData);
  }
  }
  }

  return expenseDataList;

------解决方案--------------------
如果代码相同,是不是服务器和本地的.net版本不一致导致的?