Problème d'exécution

ksandy Messages postés 11 Date d'inscription jeudi 8 juin 2006 Statut Membre Dernière intervention 7 août 2006 - 7 août 2006 à 17:13
ksandy Messages postés 11 Date d'inscription jeudi 8 juin 2006 Statut Membre Dernière intervention 7 août 2006 - 7 août 2006 à 18:38
Bonjour,
Je suis désespérée car j'ai une erreur d'exécution lorsque j'ouvre ma boîtede dialogue en mode débug sous VC++.
Programmation MFC.
L'erreur affichée est "access violation" dans la boîte de dialogue de débug de Microsoft.
L'erreur survient même pour une simple dialog box non modifiée (dialog box par défaut avec boutons "OK" et "Cancel" fournis par Microsoft)
Merci pour vos suggestions

Sandy

6 réponses

rrk275 Messages postés 540 Date d'inscription vendredi 25 juin 2004 Statut Membre Dernière intervention 1 octobre 2007 2
7 août 2006 à 17:25
Acces violation resemble a un acces de memoire non autorisé verifie les pointeurs sur ces boites de dialogues .. donne un code si tu trouve pas ..
0
ksandy Messages postés 11 Date d'inscription jeudi 8 juin 2006 Statut Membre Dernière intervention 7 août 2006
7 août 2006 à 17:38
Merci pour l'info. Mais, je dois avouer que je ne comprends pas trop.
Voici le conteni de "Error Report Contents)


Exception  information:
Code 0xc0000005
Flags 0x00000000
Record 0x000000000000000000
Adress 0x000000000000000000

Ce qui m'embête le plus c'est que le projet s'exécute bien avant mais une fois qu'on fait un clean, l'exécutable ne marche plus... ou alors quand on modifie la dialog box.

Merci!
0
rrk275 Messages postés 540 Date d'inscription vendredi 25 juin 2004 Statut Membre Dernière intervention 1 octobre 2007 2
7 août 2006 à 17:42
Il se trouve que le Adress 0x000000000000000000 me fait penser a un pointeur null mais je peux me tromper , je parlais du code source ^^
0
ksandy Messages postés 11 Date d'inscription jeudi 8 juin 2006 Statut Membre Dernière intervention 7 août 2006
7 août 2006 à 18:09
Je n'arrive pas à charger le code source. Comment on s'y prends sur ce forum? Je ne vois pas l'option "joindre fichier"
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
rrk275 Messages postés 540 Date d'inscription vendredi 25 juin 2004 Statut Membre Dernière intervention 1 octobre 2007 2
7 août 2006 à 18:10
Suffit de faire copier coller le bout qui buggue ..
0
ksandy Messages postés 11 Date d'inscription jeudi 8 juin 2006 Statut Membre Dernière intervention 7 août 2006
7 août 2006 à 18:38
Voici quelques fonctions. C'est la OnChangeMode() qui ne marche pas. Il s'agit de l'envoi d'une trame particulière qui permet de changer de mode de fonctionnement. Cest le même principe que le send command plus bas qui utilise la fonction WritePort....
Et c'est cette fonction qui est mal gérée lors de l'exécution
Merci pour l'aide

void CUCRSandMP50Dlg::OnChangeMode()
{
char EndFrame, character;
DWORD BytesTransferred,i,j,longRX,result;
char  Trame[256]="", czTrameRX[256]="", czTramemaj[256]="", TrameRX[256]="";
char TrameMode[10]={0x6,0x0,0x0,0x2,0xE,0xE,0x0,0x1,0x8,0xD};
BytesTransferred =0;


// Command to send for changing the communication mode. Switch from UCRS to MP50 mode
 if ((m_ucrs.GetState() & 0x0003)==1){
  EndFrame = ('3'-'0'); 
  czTrame += EndFrame;
  // Sending command on the serial port.(Writting)
  BytesTransferred = PortSerie.WritePort(TrameMode,10,BytesTransferred).nBytes;
   //PortSerie est définie en public dans une autre classe. Mais la présente fonction OnChangeMode qui a été rajoutée n'est pas bien gérée par le compilateur et génère une erreur lors de l'exécution.
  longRX = 0;
  if (PortSerie.WriteChar(EndFrame)) //return 0 if writting of EOF is incorrect.
   BytesTransferred ++;


  if (BytesTransferred != 11)
   GetDlgItem(IDC_EDIT8)->SetWindowText("Error when switching mode. Please try again");
  else{
   PortSerie.SetTimeouts(100,100);
   result = 0;
   i=0;j=0;


   // reception of command on the serial port. (Reading)
   do{
    if((result = PortSerie.ReadCharbyChar(&character,1).answer)==1){
     czTrameRX[longRX] = character;
     longRX ++;
     }
   }while (character != EndFrame);
 }
}
  
 else if ((m_mp.GetState() & 0x0003)==1)    
    EndFrame = ('D'-'0');// '\r';
 else
  GetDlgItem(IDC_EDIT8)->SetWindowText("Select a mode before changing it");

}

/********************************
********************************/

void CUCRSandMP50Dlg::OnSendCommand()
{
CString command, commandsent;
char longueur[4]="", crc[2]="";
char  Trame[256]="", czTrameRX[256]="", czTramemaj[256]="";
long LCR, i;
unsigned long result, BytesTransferred=0;
char *lg;
char EndFrame;




 /******************************************************************************************************
            Sending and reception of frame start here when COM1
   ******************************************************************************************************/
 PortSerie.SetTimeouts(1,1);
 // Sending command on the serial port.
// result = PortSerie.WritePort(czTrame,commandsent.GetLength(),BytesTransferred).answer;
 BytesTransferred = PortSerie.WritePort(czTrame,commandsent.GetLength(),BytesTransferred).nBytes;


  if (BytesTransferred != (DWORD)commandsent.GetLength())
   GetDlgItem(IDC_EDIT8)->SetWindowText("Error when writting on the serial port");
  else
   result = PortSerie.ReadCharbyChar(czTrameRX,BytesTransferred).answer;

  if(!result)
    GetDlgItem(IDC_EDIT8)->SetWindowText("Error when reading on the serial port");
   else {
    if(BytesTransferred != (DWORD)commandsent.GetLength())
     GetDlgItem(IDC_EDIT8)->SetWindowText("Error when reading on the serial port");
   }
}

comout Cserialcom::WritePort(char *outBuffer,DWORD nBytesToWrite,DWORD BytesTransferred)
{
comout result;
 result.answer= 0;
 result.nBytes =0;


 if(m_RSParam.hCom == NULL) return result;


 if (!WriteFile(m_RSParam.hCom, outBuffer, nBytesToWrite, &BytesTransferred, NULL)) return result;
 if (BytesTransferred == 0)   return result;
// if (!FlushFileBuffers(m_RSParam.hCom))  return 0;


 result.answer = 1;
 result.nBytes =  BytesTransferred;
 return (result);


}

typedef struct
{ //to return answer and nBytes of the operation (writting or reading)
 DWORD     answer;     //return the values of operation
 DWORD     nBytes;     // BYTES transferred when writting/reading
 CString data;
} comout;








 
0
Rejoignez-nous