...
var
  ...
  oboAccounts: IboEMCAccount;
  ...
procedure DragMsg;
  begin
  try
    oboAccounts.MoveMessage(GetUID, arvMsgId,
                            PAccount(MovedToNode.Data)^.FolderID,
                            PAccount(MovedToNode.Data)^.ProfileID, True);
    except
      on E:Exception do
      begin
        ...
      end
      else
        ...
      end;
    end;
  end;
begin
  ...
  oboAccounts := CreateEverestObject(CLASS_boEMCAccount, GetAppServer) as IboEMCAccount;
  DragMsg;
  ...
end;
function TboEMCAccount.MoveMessage(const sUID: WideString; vMsgID,
  vFolderID, vProfileID: OleVariant; bCheckAccess: WordBool): WordBool;
var
  iCount:integer;
  rsMsg: _Recordset;
  vSemaID: OleVariant;
begin
  try
   ...
      if VarIsArray(vMsgID) then
      begin
        for iCount := 0 to VarArrayHighBound(vMsgID,1)-1 do
        begin
           rsMsg :=  m_odoEMCMessage.Fetch(sUID, varToStr(vmsgid[iCount]), False);
                         //在这里设置的断点为什么是无效的呢?

           if Assigned(rsMsg) and (rsMsg.RecordCount = 1) then
           begin
             rsMsg.Fields['FLDID'].Value := vFolderID;
             rsMsg.Fields['PRFID'].Value := vProfileID;             rsMsg := m_odoEMCMessage.Update(sUID, rsMsg, True);             ...
             Result := True;
           end
           else
             RaiseValidationError(OTBusinessObject, sUID, 'TboEMCAccount.MoveMessage', EMCInvalidMessageError);
        ...
  except
    ...
  end;
end;以上是主要代码,我的程序有BUG,想单步跟踪找到错误点,可是断点不起作用。。应该怎么解决呢?试过用注释的方法来测试过,代码确实有运行到。怎样才能使设置的断点有效?

解决方案 »

  1.   

    重新build试试,再不行重新打开工程试试
      

  2.   

    在m_odoEMCMessage.Fetch执行之前把参数都显示出来看看,是不是根本没有进入循环内
      

  3.   

    把断点设在if VarIsArray(vMsgID) then 看看,不行再移动,只要在rsMsg :=  m_odoEMCMessage.Fetch(sUID, varToStr(vmsgid[iCount]), False);之前都可以
      

  4.   

    代碼if VarIsArray(vMsgID) then根本都沒有執行成功,所以設置的斷點無效,認真檢查一下看是在哪句出現了問題才致使if判斷沒有被執行到
      

  5.   

    我试过注释掉所有的代码,然后一行行放出
    if VarIsArray(vMsgID) then
    这一行代码是有执行到的而且FUNCTION从一开始设置的断点就是无效的function TboEMCAccount.MoveMessage(const sUID: WideString; vMsgID,
      vFolderID, vProfileID: OleVariant; bCheckAccess: WordBool): WordBool;
    var
      iCount:integer;
      rsMsg: _Recordset;
      vSemaID: OleVariant;
    begin
      try
        if bCheckAccess then
        begin
          if not (VarIsNull(vFolderID) or VarIsEmpty(vFolderID) or (VarToStr(vFolderID) = '')) then
          begin
            if vFolderID > 0 then
            begin
              if UpperCase(m_oboUserInfo.GetLoggedInUser(sUID)) <>
                m_oboFolder.GetThisUser(sUID, vFolderID) then
              begin
                if not m_oboUserInfo.GetAccessPass(sUID, 0, 'EMC_MOVEMESSGES') then
                  RaiseValidationError(OTBusinessObject,sUID,'TboEMCAccount.MoveMessage', AccessDenied);
              end;
            end;
          end
          else
            RaiseValidationError(OTBusinessObject, sUID, 'TboEMCAccount.MoveMessage', EMCFolderIDEmpty);          if not m_oboUserInfo.GetAccessPass(sUID, 0, 'EMC_MOVEMESSGES') then
                RaiseValidationError(OTBusinessObject,sUID,'TboEMCAccount.MoveMessage', AccessDenied);      if not (VarIsNull(vProfileID) or VarIsEmpty(vProfileID) or (VarToStr(vProfileID) = '')) then
          begin
            if UpperCase(m_oboUserInfo.GetLoggedInUser(sUID)) <>
              m_odoEMCAccount.GetThisUser(sUID, vProfileID) then
            begin
              if not m_oboUserInfo.GetAccessPass(sUID, 0, 'EMC_MOVEMESSGES') then
                RaiseValidationError(OTBusinessObject,sUID,'TboEMCAccount.MoveMessage', AccessDenied);
            end;
          end
          else
            RaiseValidationError(OTBusinessObject, sUID, 'TboEMCAccount.MoveMessage', EMCProfileIDIsNull);
        end;      if VarIsArray(vMsgID) then
          begin
            for iCount := 0 to VarArrayHighBound(vMsgID,1)-1 do
            begin
               rsMsg :=  m_odoEMCMessage.Fetch(sUID, varToStr(vmsgid[iCount]), False);
               if Assigned(rsMsg) and (rsMsg.RecordCount = 1) then
               begin
                 rsMsg.Fields['FLDID'].Value := vFolderID;
                 rsMsg.Fields['PRFID'].Value := vProfileID;             rsMsg := m_odoEMCMessage.Update(sUID, rsMsg, True);      // if html formated mails then we will need to set the cids according to the
          // new attachments so that the images can be rendered properly...
                 if (rsMsg.Fields['MESSAGE_FORMAT'].Value = 2) and
                 (rsMsg.Fields['HASATTACH'].Value = 'T') then
                 begin
                   UpdateHtmlMessage(sUID, rsMsg.Fields['MSGID'].Value,
                   rsMsg.Fields['BODY'].Value, bCheckAccess);
                 end;             Result := True;
               end
               else
                 RaiseValidationError(OTBusinessObject, sUID, 'TboEMCAccount.MoveMessage', EMCInvalidMessageError);
            end;
          end
        else
        begin
             rsMsg :=  m_odoEMCMessage.Fetch(sUID, vMsgID, False);
            if Assigned(rsMsg) and (rsMsg.RecordCount = 1) then
            begin
              rsMsg.Fields['FLDID'].Value := vFolderID;
              rsMsg.Fields['PRFID'].Value := vProfileID;          rsMsg := m_odoEMCMessage.Update(sUID, rsMsg, True);          // if html formated mails then we will need to set the cids according to the
              // new attachments so that the images can be rendered properly...
              if (rsMsg.Fields['MESSAGE_FORMAT'].Value = 2) and
                (rsMsg.Fields['HASATTACH'].Value = 'T') then
              begin
                UpdateHtmlMessage(sUID, rsMsg.Fields['MSGID'].Value,
                  rsMsg.Fields['BODY'].Value);
              end;          Result := True;
            end
            else
              RaiseValidationError(OTBusinessObject, sUID, 'TboEMCAccount.MoveMessage', EMCInvalidMessageError);//请注意,程序因为BUG原因,会执行到这一句,所以我想要实现对rsMsg的值的跟踪,但是现在设置不了断点。    end;  except
        on E:Exception do
        begin
          SetAbort;
          if (not VarIsEmpty(vSemaID)) and m_oboSemaphore.LockExists(sUID, vSemaID) then
            m_oboSemaphore.UnLockRecord(sUID, vSemaID);
          HandleEverestError(OTBusinessObject, sUID, 'TboEMCAccount.MoveMessage', EMCMoveMessageError, E);
          Result := False;
        end;
      end;
    end;
      

  6.   

    我是想单步啊,关键是设置的断点是无效,程序根本就不停,直接就跑到except里面了,用SHOWMESSAGE()来代替断点的时候,运行时,程序直接就卡住了,天天在网上找资料,都没有解决这个问题,请调试高手们多多指教。
      

  7.   

    直接跳到except里说明发生了异常啊
      

  8.   

    一、如果Project->Options->Debug information前面的勾去掉了,则此工程中所有的断点无效。二、在工程组中联调时偶尔会出现;三、//if VarIsArray(vMsgID) then
        //这一行代码是有执行到的
        这一行代码是有执行到,不表示其判断结果一定是True
      

  9.   

    正是有错误,所以才要断点跟踪,if Assigned(rsMsg) and (rsMsg.RecordCount = 1) then在这条件判断的时候,为FALSE,所以跑到了,ELSE部分(提示错误),所以我想要跟踪到rsMsg :=  m_odoEMCMessage.Fetch(sUID, varToStr(vmsgid[iCount]), False); 中的rsmsg的取值,有没有其它办法让我看到rsmsg的数据啊
      

  10.   

    看看你的Fetch定义的参数,应该是实参错了。
    所以m_odoEMCMessage.Fetch执行不了
      

  11.   

    delphi有时候会发生一些关于断点跟踪调试的错误,有时候,明明给的是A路径下的pas文件,他非要打开B目录下的pas文件去跟踪。遇到这样的情况,首先确定你打开并要跟踪的那个pas文件是不是真正被编译到你程序中的pas文件。
    有些人觉得这很可笑,但是如果你的代码量大了,备份多了,就很可能出现逆当前打开的pas文件不是你真正被编译的pas文件。
    如果你的工程文件和你的pas不在一个路径下,检查你delphi中的查找路径,看看是不是包含了你当前打开的那个pas文件;再检查一下dpr文件的内容,看看其中包含的你无法跟踪的那个pas是不是就是你当前打开的那个。
    备份你的源代码,然后在资源管理器中查找你不能跟踪的那个pas,看看有多少?如果有多个,删除多余的,只留下你认为是对的那个(注意别把备份的也删除了),然后在编译跟踪试试看
    总之就是保证你当前打开的pas是你真正最好被编译的pas就行
      

  12.   


    可使用showmessage来观察,或者借助工具codesite来判断