IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C++ Discussion :

Problème de retour d'interface DCOM


Sujet :

C++

  1. #1
    Membre éclairé Avatar de sylvain.cool
    Profil pro
    Étudiant
    Inscrit en
    Janvier 2006
    Messages
    242
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Janvier 2006
    Messages : 242
    Par défaut Problème de retour d'interface DCOM
    Bonjour,

    J'ai une application distribué qui permet de passer une structure via d'un PC à un autre via DCOM.

    Ma structure est une interface DCOM composé d'autre interface, elles-mêmes composé d'interfaces et etc... jusqu'à arriver à des types simples.

    En gros l'application cliente envoie la structure vers le serveur. Le serveur la copie et traite les données. Enfin, le client récupère la structure.

    Mon problème est que j'arrive à envoyer le structure, mais je la récupère à moitié.

    Pourtant, je fais la même chose coté client et serveur.

    Code client: création de l'interface à envoyer.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
     
                    TCOMITMatrixIntCOM matrice = CoTMatrixIntCOM::Create();
     
    		matrice.set_nCols(nCols); 
    		matrice.set_nRows(nRows);
    		matrice.set_roiTop(roiTop);
    		matrice.set_roiLeft(roiLeft);
    		matrice.set_roiRight(roiRight);
    		matrice.set_roiBottom(roiBottom);
     
    		LPSAFEARRAY lpsa;
    		lpsa = SafeArrayCreateVector(sizeof(int),0,data.size());
    		long Valeur,Position;
    		for(i=0; i<data.size(); i++){
    			Position = i;
    			Valeur = data[i];
    			SafeArrayPutElement(lpsa, &Position, &Valeur);
    		} 
    		matrice.set_data(lpsa);
    		SafeArrayDestroy(lpsa);
     
     
    			// iRoi
    		TCOMITVectorAnsiStringCOM iRoi = CoTVectorAnsiStringCOM::Create();
    		for(i=0; i<roiList.size(); i++)
    		{
    			iRoi.set_element(i,roiList[i].c_str());
                    }
     
     
    			// currentRegion
    		TCOMITRegionCOM cReg = CoTRegionCOM::Create();
    		cReg.list = iRoi;
     
     
    			// list (regions)
    		TCOMITVectorAnsiStringCOM * iReg;
    		TCOMITRegionCOM * reg;
    		TCOMITVectorTRegionCOM listRegion = CoTVectorTRegionCOM::Create(); 
    		for(i=0; i<regionList.size(); i++)
    		{
    			reg = new TCOMITRegionCOM;
    			*reg = CoTRegionCOM::Create(); 
    			iReg = new TCOMITVectorAnsiStringCOM;
    			*iReg = CoTVectorAnsiStringCOM::Create();
     
    			for(j=0; j<regionList[i].size(); j++)
    			{
    				iReg->set_element(j,regionList[i][j].c_str());
                            }
     
    			reg->set_list((TVectorAnsiStringCOM*)*iReg);	
    			listRegion.set_element(i,(TRegionCOM*)*reg);
    		}
     
     
    			// regions
    		TCOMITRegionsCOM regions = CoTRegionsCOM::Create();
    		regions.currentRegion = cReg;
    		regions.list = listRegion;
     
     
    			// Image
    		TCOMITImageDataCOM image = CoTImageDataCOM::Create();
    		image.iMatrix = matrice;
    		image.regions = regions;
    Code client: Envoi, traitement et retour.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
    		TCOMIObjetRunCOM objetDistant = CoObjetRunCOM::CreateRemote(L"10.167.20.154");
    		TImageDataCOM * imageResult;
     
    		reponse = objetDistant.set_image((TImageDataCOM*)image);
    		analyseReponse(reponse, "set_image");
    	   	if(SUCCEEDED(reponse)){
    			reponse = objetDistant.Run();
    			analyseReponse(reponse, "Run");
    			if(SUCCEEDED(reponse)){
    				reponse = objetDistant.get_image(&imageResult);
    				analyseReponse(reponse, "get_image");
    			}
    		}
    Code serveur: Création de l'interface pour le retour des données
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
     
    STDMETHODIMP TObjetRunCOMImpl::get_image(TImageDataCOM** Value)
    {
      try
      {
    	int i,j;
    	HRESULT reponse;
     
     
    		// iMatrix
    	TCOMITMatrixIntCOM matrice = CoTMatrixIntCOM::Create();
     
    	matrice.set_nCols(nCols); 
    	matrice.set_nRows(nRows);
    	matrice.set_roiTop(roiTop);
    	matrice.set_roiLeft(roiLeft);
    	matrice.set_roiRight(roiRight);
    	matrice.set_roiBottom(roiBottom);
     
    	LPSAFEARRAY lpsa;
    	lpsa = SafeArrayCreateVector(sizeof(int),0,data.size());
    	long Valeur,Position;
    	for(i=0; i<data.size(); i++){
    		Position = i;
    		Valeur = data[i];
    		SafeArrayPutElement(lpsa, &Position, &Valeur);
    	} 
    	matrice.set_data(lpsa);
    	SafeArrayDestroy(lpsa);
     
     
    		// iRoi
    	TCOMITVectorAnsiStringCOM iRoi = CoTVectorAnsiStringCOM::Create();
    	for(i=0; i<roiList.size(); i++)
    		iRoi.set_element(i,roiList[i].c_str());
     
     
    		// currentRegion
    	TCOMITRegionCOM cReg = CoTRegionCOM::Create();
    	cReg.set_list((TVectorAnsiStringCOM*)iRoi);
     
     
    		// list (regions)
    	TCOMITVectorAnsiStringCOM * iReg;
    	TCOMITRegionCOM * reg;
    	TCOMITVectorTRegionCOM listRegion = CoTVectorTRegionCOM::Create(); 
    	for(i=0; i<regionList.size(); i++){
    		reg = new TCOMITRegionCOM;
    		*reg = CoTRegionCOM::Create(); 
    		iReg = new TCOMITVectorAnsiStringCOM;
    		*iReg = CoTVectorAnsiStringCOM::Create();
     
    		for(j=0; j<regionList[i].size(); j++)
    			iReg->set_element(j,regionList[i][j].c_str());
     
    		reg->set_list((TVectorAnsiStringCOM*)*iReg);	
    		listRegion.set_element(i,(TRegionCOM*)*reg);
    	}
     
     
    		// regions
    	TCOMITRegionsCOM regions = CoTRegionsCOM::Create();
    	regions.set_currentRegion((TRegionCOM*)cReg);
    	regions.set_list((TVectorTRegionCOM*)listRegion);
     
     
    		// Image  	
    	TCOMITImageDataCOM imageResult;
    	imageResult = CoTImageDataCOM::Create();
     
    	reponse = imageResult->set_regions((TRegionsCOM*)regions);
    	analyseReponse(reponse, "set_regions");
     
    	reponse = imageResult->set_iMatrix((TMatrixIntCOM*)matrice);
    	analyseReponse(reponse, "set_iMatrix");
     
    	*Value = imageResult;
      }
      catch(Exception &e)
      {
        return Error(e.Message.c_str(), IID_IObjetRunCOM);
      }
      return S_OK;
    };
    Au final, coté client, je récupère parfaitement ma matrice, mais pas mes régions.

    Alors qu'à l'envoi, je récupère tout. Et pourtant je fais la même chose!

    Une idée?
    Une question pour compléter le problème?

    Merci d'avance pour toute réponse.

  2. #2
    Membre éclairé Avatar de sylvain.cool
    Profil pro
    Étudiant
    Inscrit en
    Janvier 2006
    Messages
    242
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Janvier 2006
    Messages : 242
    Par défaut
    Je rajoute que côté serveur, dans la fonction get_image, l'interface regions est bien implanté dans l'interface image, mais disparait en arrivant côté client. Contrairement à la matrice qui est présente côté client et serveur.

  3. #3
    Expert éminent
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 397
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 397
    Par défaut
    Peux-tu montrer le code IDL ?
    C'est lui qui contient les informations pour le marshalling...

    PS: C'est du Borland ? Je n'y connais pas grand-chose aux wrappers COM de Borland...
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  4. #4
    Membre éclairé Avatar de sylvain.cool
    Profil pro
    Étudiant
    Inscrit en
    Janvier 2006
    Messages
    242
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Janvier 2006
    Messages : 242
    Par défaut
    Oui, c'est du Borland.

    Je commence à me demander si c'est pas Borland qui a du mal.

    Sinon, voici le code IDL.
    Je n'ai mis que les interfaces et pas les CoClass.

    ITImageDataCOM:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    [
      uuid(405A19ED-F633-4B83-B81D-DDADC3CE38F7), 
      version(1.0), 
      helpstring("Dispatch interface for TImageDataCOM Object"), 
      dual, 
      oleautomation
    ]
     interface ITImageDataCOM: IDispatch
    {
      [
      propget, 
      id(0x000000C9)
      ]
      HRESULT _stdcall regions([out, retval] TRegionsCOM ** Value /*Warning: unable to validate structure name: */ );
      [
      propput, 
      id(0x000000C9)
      ]
      HRESULT _stdcall regions([in] TRegionsCOM * Value /*Warning: unable to validate structure name: */ );
      [
      propget, 
      id(0x000000CA)
      ]
      HRESULT _stdcall iMatrix([out, retval] TMatrixIntCOM ** Value /*Warning: unable to validate structure name: */ );
      [
      propput, 
      id(0x000000CA)
      ]
      HRESULT _stdcall iMatrix([in] TMatrixIntCOM * Value /*Warning: unable to validate structure name: */ );
    };
    ITMatrixIntCOM:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    [
      uuid(81A4A6B8-4269-4DCB-B218-2ED02D1787D8), 
      version(1.0), 
      helpstring("Dispatch interface for TMatrixIntCOM Object"), 
      dual, 
      oleautomation
    ]
     interface ITMatrixIntCOM: IDispatch
    {
      [
      propget, 
      id(0x000000C9)
      ]
      HRESULT _stdcall roiTop([out, retval] int * Value );
      [
      propput, 
      id(0x000000C9)
      ]
      HRESULT _stdcall roiTop([in] int Value );
      [
      propget, 
      id(0x000000CA)
      ]
      HRESULT _stdcall roiLeft([out, retval] int * Value );
      [
      propput, 
      id(0x000000CA)
      ]
      HRESULT _stdcall roiLeft([in] int Value );
      [
      propget, 
      id(0x000000CB)
      ]
      HRESULT _stdcall roiRight([out, retval] int * Value );
      [
      propput, 
      id(0x000000CB)
      ]
      HRESULT _stdcall roiRight([in] int Value );
      [
      propget, 
      id(0x000000CC)
      ]
      HRESULT _stdcall roiBottom([out, retval] int * Value );
      [
      propput, 
      id(0x000000CC)
      ]
      HRESULT _stdcall roiBottom([in] int Value );
      [
      propget, 
      id(0x000000CD)
      ]
      HRESULT _stdcall nRows([out, retval] int * Value );
      [
      propput, 
      id(0x000000CD)
      ]
      HRESULT _stdcall nRows([in] int Value );
      [
      propget, 
      id(0x000000CE)
      ]
      HRESULT _stdcall nCols([out, retval] int * Value );
      [
      propput, 
      id(0x000000CE)
      ]
      HRESULT _stdcall nCols([in] int Value );
      [
      propget, 
      id(0x000000CF)
      ]
      HRESULT _stdcall data([out, retval] SAFEARRAY(int) * Value );
      [
      propput, 
      id(0x000000CF)
      ]
      HRESULT _stdcall data([in] SAFEARRAY(int) Value );
    };
    ITRegionCOM:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    [
      uuid(BF6AB5E9-C522-400E-8B0E-A9891AB67839), 
      version(1.0), 
      helpstring("Dispatch interface for TRegionsCOM Object"), 
      dual, 
      oleautomation
    ]
     interface ITRegionsCOM: IDispatch
    {
      [
      propget, 
      id(0x000000C9)
      ]
      HRESULT _stdcall list([out, retval] TVectorTRegionCOM ** Value /*Warning: unable to validate structure name: */ );
      [
      propput, 
      id(0x000000C9)
      ]
      HRESULT _stdcall list([in] TVectorTRegionCOM * Value /*Warning: unable to validate structure name: */ );
      [
      propget, 
      id(0x000000CA)
      ]
      HRESULT _stdcall currentRegion([out, retval] TRegionCOM ** Value /*Warning: unable to validate structure name: */ );
      [
      propput, 
      id(0x000000CA)
      ]
      HRESULT _stdcall currentRegion([in] TRegionCOM * Value /*Warning: unable to validate structure name: */ );
    };
    ITVectorTRegionCOM:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    [
      uuid(04D0892E-44E8-4997-B521-70771755DE24), 
      version(1.0), 
      helpstring("Dispatch interface for TVectorTRegionCOM Object"), 
      dual, 
      oleautomation
    ]
     interface ITVectorTRegionCOM: IDispatch
    {
      [
      propget, 
      id(0x000000C9)
      ]
      HRESULT _stdcall element([in] int Position, [out, retval] TRegionCOM ** Value /*Warning: unable to validate structure name: */ );
      [
      propput, 
      id(0x000000C9)
      ]
      HRESULT _stdcall element([in] int Position, [in] TRegionCOM * Value /*Warning: unable to validate structure name: */ );
      [
      propget, 
      id(0x000000CA)
      ]
      HRESULT _stdcall tailleTab([out, retval] int * Value );
      [
      propput, 
      id(0x000000CA)
      ]
      HRESULT _stdcall tailleTab([in] int Value );
    };
    ITRegionCOM:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    [
      uuid(F2D28F27-FAA6-439C-9579-874D3FDCFE12), 
      version(1.0), 
      helpstring("Dispatch interface for TRegionCOM Object"), 
      dual, 
      oleautomation
    ]
     interface ITRegionCOM: IDispatch
    {
      [
      propget, 
      id(0x000000C9)
      ]
      HRESULT _stdcall list([out, retval] TVectorAnsiStringCOM ** Value /*Warning: unable to validate structure name: */ );
      [
      propput, 
      id(0x000000C9)
      ]
      HRESULT _stdcall list([in] TVectorAnsiStringCOM * Value /*Warning: unable to validate structure name: */ );
    };
    ITVectorAnsiStringCOM:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    [
      uuid(A4AB2851-B88F-4101-B78E-54A60DA6EABB), 
      version(1.0), 
      helpstring("Dispatch interface for TVectorAnsiStringCOM Object"), 
      dual, 
      oleautomation
    ]
     interface ITVectorAnsiStringCOM: IDispatch
    {
      [
      propget, 
      id(0x000000C9)
      ]
      HRESULT _stdcall element([in] int Position, [out, retval] LPSTR * Value );
      [
      propput, 
      id(0x000000C9)
      ]
      HRESULT _stdcall element([in] int Position, [in] LPSTR Value );
      [
      propget, 
      id(0x000000CA)
      ]
      HRESULT _stdcall tailleTab([out, retval] int * Value );
      [
      propput, 
      id(0x000000CA)
      ]
      HRESULT _stdcall tailleTab([in] int Value );
    };
    ObjetRunCOM:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    [
      uuid(23D44C29-B3A6-423E-BAFA-D08428AC54D9), 
      version(1.0), 
      helpstring("Dispatch interface for ObjetRunCOM Object"), 
      dual, 
      oleautomation
    ]
     interface IObjetRunCOM: IDispatch
    {
      [
      id(0x000000C9)
      ]
      HRESULT _stdcall Run( void );
      [
      propget, 
      id(0x000000CA)
      ]
      HRESULT _stdcall image([out, retval] TImageDataCOM ** Value /*Warning: unable to validate structure name: */ );
      [
      propput, 
      id(0x000000CA)
      ]
      HRESULT _stdcall image([in] TImageDataCOM * Value /*Warning: unable to validate structure name: */ );
    };

  5. #5
    Expert éminent
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 397
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 397
    Par défaut
    Déjà, ça me parait bizarre que tes fonctions prennent la coclass (TRegionCOM) en paramètre au lieu de l'interface (ITRegionCOM)...

    Et j'ai l'impression que les warnings sont d'accord avec moi : C'est ce qui doit faire foirer le marshalling...
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  6. #6
    Expert éminent
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 397
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 397
    Par défaut
    PS: Je crois bien me souvenir qu'en COM comme en .Net, les propriétés sont traditionnellement supposées commencer par une majuscule, comme les méthodes. Seules les variables membres (et une interface n'en a pas) sont supposées commencer par une minuscule...
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  7. #7
    Membre éclairé Avatar de sylvain.cool
    Profil pro
    Étudiant
    Inscrit en
    Janvier 2006
    Messages
    242
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Janvier 2006
    Messages : 242
    Par défaut
    J'ai changé les CoClass par les interfaces, mais ça ne change rien. J'ai toujours même résultat.
    Les warnings sont toujours là.

    C'est quand même bizarre que ça marche dans un sens et pas dans l'autre.

  8. #8
    Expert éminent
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 397
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 397
    Par défaut
    Bizarre.
    Vérifie que les interfaces sont déclarées dans le bon ordre...
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  9. #9
    Membre éclairé Avatar de sylvain.cool
    Profil pro
    Étudiant
    Inscrit en
    Janvier 2006
    Messages
    242
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Janvier 2006
    Messages : 242
    Par défaut
    Oki, je vais faire ça demain et je te tiens au courant.
    Ça m'étonnerait que ça vienne de là, mais au point où j'en suis.

  10. #10
    Membre éclairé Avatar de sylvain.cool
    Profil pro
    Étudiant
    Inscrit en
    Janvier 2006
    Messages
    242
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Janvier 2006
    Messages : 242
    Par défaut
    J'ai tout refait, mais j'ai toujours le même problème.

    Les interfaces sont déclarées dans le bon ordre, j'ai remplacé les CoClass par des interfaces dans les propriétés, mais j'ai toujours les warnings dans le code idl.

    J'ai tout repris (recodé) depuis le début pour voir ce que cela donnait. Mais ça n'a rien changé.

    Ca marche toujours dans le sens Client->Serveur, mais jamais totalement dans l'autre (Serveur->Client).

    Par contre, je crois qu'il se plante dans le marshalling côté serveur. En effet, normalement quand le client se termine, la fenêtre du serveur se ferme aussi.
    Ce n'est pas le cas quand j'essaie de retourner l'image. La fenêtre ne se ferme pas, mais la méthode réussie (HRESULT=S_OK).

    Pour info, le nouveau code.

    IDL:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
     
    [
      uuid(4609E683-0944-4456-A849-66BC6B0AB902), 
      version(1.0), 
      helpstring("Serveur Library")
     
    ]
    library Serveur
    {
     
      importlib("STDOLE2.TLB");
     
      [
        uuid(7A740506-18A2-4C0B-90AE-A653BBEBDF6F), 
        version(1.0), 
        helpstring("Dispatch interface for TVectorAnsiStringCOM Object"), 
        dual, 
        oleautomation
      ]
       interface ITVectorAnsiStringCOM: IDispatch
      {
        [
        propget, 
        id(0x000000C9)
        ]
        HRESULT _stdcall taille([out, retval] int * Value );
        [
        propput, 
        id(0x000000C9)
        ]
        HRESULT _stdcall taille([in] int Value );
        [
        propget, 
        id(0x000000CA)
        ]
        HRESULT _stdcall element([out, retval] LPSTR * Value );
        [
        propput, 
        id(0x000000CA)
        ]
        HRESULT _stdcall element([in] LPSTR Value );
      };
     
      [
        uuid(66FBB4CE-E85C-420D-8765-0734A7D386F8), 
        version(1.0), 
        helpstring("TVectorAnsiStringCOM Object")
      ]
      coclass TVectorAnsiStringCOM
      {
        [default] interface ITVectorAnsiStringCOM;
      };
     
      [
        uuid(9AED97B7-9A5D-49E5-BEEB-BF4444C8D115), 
        version(1.0), 
        helpstring("TRegionCOM Object")
      ]
      coclass TRegionCOM
      {
        [default] interface ITRegionCOM;
      };
     
      [
        uuid(8D3A6B08-9B14-41A3-8CEC-E825C7BD37EC), 
        version(1.0), 
        helpstring("TVectorTRegionCOM Object")
      ]
      coclass TVectorTRegionCOM
      {
        [default] interface ITVectorTRegionCOM;
      };
     
      [
        uuid(9C50EC1B-D8A2-4B34-86CF-D1206E18AFF6), 
        version(1.0), 
        helpstring("TRegionsCOM Object")
      ]
      coclass TRegionsCOM
      {
        [default] interface ITRegionsCOM;
      };
     
      [
        uuid(89C82050-025D-4B17-BD70-7D1FA2B22A7B), 
        version(1.0), 
        helpstring("Dispatch interface for TMatrixIntCOM Object"), 
        dual, 
        oleautomation
      ]
       interface ITMatrixIntCOM: IDispatch
      {
        [
        propget, 
        id(0x000000C9)
        ]
        HRESULT _stdcall nRows([out, retval] int * Value );
        [
        propput, 
        id(0x000000C9)
        ]
        HRESULT _stdcall nRows([in] int Value );
        [
        propget, 
        id(0x000000CA)
        ]
        HRESULT _stdcall nCols([out, retval] int * Value );
        [
        propput, 
        id(0x000000CA)
        ]
        HRESULT _stdcall nCols([in] int Value );
        [
        propget, 
        id(0x000000CB)
        ]
        HRESULT _stdcall roiBottom([out, retval] int * Value );
        [
        propput, 
        id(0x000000CB)
        ]
        HRESULT _stdcall roiBottom([in] int Value );
        [
        propget, 
        id(0x000000CC)
        ]
        HRESULT _stdcall roiTop([out, retval] int * Value );
        [
        propput, 
        id(0x000000CC)
        ]
        HRESULT _stdcall roiTop([in] int Value );
        [
        propget, 
        id(0x000000CD)
        ]
        HRESULT _stdcall roiLeft([out, retval] int * Value );
        [
        propput, 
        id(0x000000CD)
        ]
        HRESULT _stdcall roiLeft([in] int Value );
        [
        propget, 
        id(0x000000CE)
        ]
        HRESULT _stdcall roiRight([out, retval] int * Value );
        [
        propput, 
        id(0x000000CE)
        ]
        HRESULT _stdcall roiRight([in] int Value );
        [
        propget, 
        id(0x000000CF)
        ]
        HRESULT _stdcall data([out, retval] SAFEARRAY(int) * Value );
        [
        propput, 
        id(0x000000CF)
        ]
        HRESULT _stdcall data([in] SAFEARRAY(int) Value );
      };
     
      [
        uuid(FB282122-08D4-45D0-82B5-3B8863AAA0D3), 
        version(1.0), 
        helpstring("TMatrixIntCOM Object")
      ]
      coclass TMatrixIntCOM
      {
        [default] interface ITMatrixIntCOM;
      };
     
      [
        uuid(75F1C8A2-3437-412A-9425-4E2C25D18D59), 
        version(1.0), 
        helpstring("TImageDataCOM Object")
      ]
      coclass TImageDataCOM
      {
        [default] interface ITImageDataCOM;
      };
     
      [
        uuid(55C7EBA9-2F62-4EA9-903F-E6AD22990DE6), 
        version(1.0), 
        helpstring("Dispatch interface for TRegionCOM Object"), 
        dual, 
        oleautomation
      ]
       interface ITRegionCOM: IDispatch
      {
        [
        propget, 
        id(0x000000C9)
        ]
        HRESULT _stdcall list([out, retval] ITVectorAnsiStringCOM ** Value /*Warning: unable to validate structure name: */ );
        [
        propput, 
        id(0x000000C9)
        ]
        HRESULT _stdcall list([in] ITVectorAnsiStringCOM * Value /*Warning: unable to validate structure name: */ );
      };
     
      [
        uuid(9155E9D1-BA6C-4FCD-8EB4-CDA6273EF83C), 
        version(1.0), 
        helpstring("Dispatch interface for TVectorTRegionCOM Object"), 
        dual, 
        oleautomation
      ]
       interface ITVectorTRegionCOM: IDispatch
      {
        [
        propget, 
        id(0x000000C9)
        ]
        HRESULT _stdcall taille([out, retval] int * Value );
        [
        propput, 
        id(0x000000C9)
        ]
        HRESULT _stdcall taille([in] int Value );
        [
        propget, 
        id(0x000000CA)
        ]
        HRESULT _stdcall element([out, retval] ITRegionCOM ** Value /*Warning: unable to validate structure name: */ );
        [
        propput, 
        id(0x000000CA)
        ]
        HRESULT _stdcall element([in] ITRegionCOM * Value /*Warning: unable to validate structure name: */ );
      };
     
      [
        uuid(377D91AB-1D3D-4286-98B3-98B0ABD20EA6), 
        version(1.0), 
        helpstring("Dispatch interface for TRegionsCOM Object"), 
        dual, 
        oleautomation
      ]
       interface ITRegionsCOM: IDispatch
      {
        [
        propget, 
        id(0x000000C9)
        ]
        HRESULT _stdcall list([out, retval] ITVectorTRegionCOM ** Value /*Warning: unable to validate structure name: */ );
        [
        propput, 
        id(0x000000C9)
        ]
        HRESULT _stdcall list([in] ITVectorTRegionCOM * Value /*Warning: unable to validate structure name: */ );
        [
        propget, 
        id(0x000000CA)
        ]
        HRESULT _stdcall currentRegion([out, retval] ITRegionCOM ** Value /*Warning: unable to validate structure name: */ );
        [
        propput, 
        id(0x000000CA)
        ]
        HRESULT _stdcall currentRegion([in] ITRegionCOM * Value /*Warning: unable to validate structure name: */ );
      };
     
      [
        uuid(9C3F32A0-DE0A-4AF7-B213-C0D86C875D8C), 
        version(1.0), 
        helpstring("Dispatch interface for TImageDataCOM Object"), 
        dual, 
        oleautomation
      ]
       interface ITImageDataCOM: IDispatch
      {
        [
        propget, 
        id(0x000000C9)
        ]
        HRESULT _stdcall regions([out, retval] ITRegionsCOM ** Value /*Warning: unable to validate structure name: */ );
        [
        propput, 
        id(0x000000C9)
        ]
        HRESULT _stdcall regions([in] ITRegionsCOM * Value /*Warning: unable to validate structure name: */ );
        [
        propget, 
        id(0x000000CA)
        ]
        HRESULT _stdcall iMatrix([out, retval] ITMatrixIntCOM ** Value /*Warning: unable to validate structure name: */ );
        [
        propput, 
        id(0x000000CA)
        ]
        HRESULT _stdcall iMatrix([in] ITMatrixIntCOM * Value /*Warning: unable to validate structure name: */ );
      };
     
    };
    Création de l'interface image à envoyé au serveur et appel à l'objet distant:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
     
    		//----------------------------------------------------------------------
    		// Création de l'interface
    		//----------------------------------------------------------------------
    		//matrice
    		TCOMITMatrixIntCOM matrice = CoTMatrixIntCOM::Create();
     
    		matrice->set_nRows(m_nRows); 
    		matrice->set_nCols(m_nCols);
    		matrice->set_roiTop(m_roiTop);
    		matrice->set_roiBottom(m_roiBottom);
    		matrice->set_roiLeft(m_roiLeft);
    		matrice->set_roiRight(m_roiRight);
     
    		LPSAFEARRAY lpsa;
    		long Position,Valeur;
    		int tailleTableau = m_data.size();
     
    		lpsa = SafeArrayCreateVector(sizeof(int), 0, m_data.size());
     
    		for(i=0; i<tailleTableau; i++)
    		{
    			Position = i;
    			Valeur = m_data[i];
    			SafeArrayPutElement(lpsa, &Position, &Valeur);
    		}
     
    		matrice->set_data(lpsa);
     
     
    		//currentRegion
    		TCOMITVectorAnsiStringCOM listOfRoi = CoTVectorAnsiStringCOM::Create();
    		tailleTableau = m_listOfRoi.size();
    		for(i=0; i<tailleTableau; i++)
    		{
    			listOfRoi->set_element(i, m_listOfRoi[i].c_str());
    		}
     
    		TCOMITRegionCOM region = CoTRegionCOM::Create();
    		region->set_list((ITVectorAnsiStringCOM*)listOfRoi);
     
    		//listOfRegion
    		TCOMITVectorTRegionCOM listOfRegion = CoTVectorTRegionCOM::Create();
    		TCOMITVectorAnsiStringCOM * listOfRoiTmp;
    		TCOMITRegionCOM * regionTmp;
    		int tailleTableau2;
     
    		tailleTableau = m_listOfRegion.size();
     
    		for(i=0; i<tailleTableau; i++)
    		{
    			listOfRoiTmp = new TCOMITVectorAnsiStringCOM;
    			*listOfRoiTmp = CoTVectorAnsiStringCOM::Create();
    			regionTmp = new TCOMITRegionCOM;
    			*regionTmp = CoTRegionCOM::Create();
    			tailleTableau2 = m_listOfRegion[i].size();
    			for(j=0; j<tailleTableau2; j++)
    			{
    				(*listOfRoiTmp)->set_element(j, m_listOfRegion[i][j].c_str());
    			}
    			(*regionTmp)->set_list((ITVectorAnsiStringCOM*)*listOfRoiTmp);
    			listOfRegion->set_element(i,(ITRegionCOM*)*regionTmp);
    		}
     
    		//regions
    		TCOMITRegionsCOM regions = CoTRegionsCOM::Create();
    		regions->set_currentRegion((ITRegionCOM*)region);
    		regions->set_list((ITVectorTRegionCOM*)listOfRegion);
     
     
    		//image
    		TCOMITImageDataCOM image = CoTImageDataCOM::Create();
    		image->set_iMatrix((ITMatrixIntCOM*)matrice);
    		image->set_regions((ITRegionsCOM*)regions);
     
     
     
                    //----------------------------------------------------------------------
    		// Création et appel de l'objet distant
    		//----------------------------------------------------------------------
    		TCOMIObjetRun objetDistant = CoObjetRun::CreateRemote(L"UC06P1556");
    		ITImageDataCOM * imageResult;
     
    		reponse = objetDistant->set_image((ITImageDataCOM*)image);
    		analyseReponse(reponse, "set_image");
     
    		if(SUCCEEDED(reponse))
    		{
    			reponse = objetDistant->run();
    			analyseReponse(reponse, "run");
    			clearDonnees();
    			afficherDonnees();
     
    			if(SUCCEEDED(reponse))
    			{
    				reponse = objetDistant->get_image(&imageResult);
    				analyseReponse(reponse, "get_image");
    				if(SUCCEEDED(reponse))
    				{
    					setAvecImgResult(imageResult);
    					afficherDonnees();
    				}
    			}
    		}
    Méthode get_image côté serveur:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
     
    STDMETHODIMP TObjetRunImpl::get_image(ITImageDataCOM** Value)
    {
      try
      {
    	int i,j;
    	HRESULT reponse;
    	AnsiString texte; 
     
    	texte = "-------------------------";
    	Form1->Memo1->Lines->Add(texte); 
     
    	texte = "get_image: ";
    	Form1->Memo1->Lines->Add(texte); 
     
     
     
    	//matrice 
    	texte = "image: ";
    	Form1->Memo1->Lines->Add(texte); 
     
    	TCOMITMatrixIntCOM matrice = CoTMatrixIntCOM::Create();
     
    	matrice->set_nRows(m_nRows); 
    	matrice->set_nCols(m_nCols);
    	matrice->set_roiTop(m_roiTop);
    	matrice->set_roiBottom(m_roiBottom);
    	matrice->set_roiLeft(m_roiLeft);
    	matrice->set_roiRight(m_roiRight);
     
    	LPSAFEARRAY lpsa;
    	long Position,Valeur;
    	int tailleTableau = m_data.size();
     
    	lpsa = SafeArrayCreateVector(sizeof(int), 0, m_data.size());
     
    	for(i=0; i<tailleTableau; i++)
    	{
    		Position = i;
    		Valeur = m_data[i];
    		SafeArrayPutElement(lpsa, &Position, &Valeur);
    	}
     
    	matrice->set_data(lpsa);
     
     
    	//currentRegion
    	texte = "currentRegion: ";
    	Form1->Memo1->Lines->Add(texte); 
     
    	TCOMITVectorAnsiStringCOM listOfRoi = CoTVectorAnsiStringCOM::Create();
    	tailleTableau = m_listOfRoi.size();
    	for(i=0; i<tailleTableau; i++)
    	{
    		listOfRoi->set_element(i, m_listOfRoi[i].c_str());
    	}
     
    	TCOMITRegionCOM region = CoTRegionCOM::Create();
    	region->set_list((ITVectorAnsiStringCOM*)listOfRoi);
     
    	//listOfRegion  
    	texte = "listOfRegion: ";
    	Form1->Memo1->Lines->Add(texte);
     
    	TCOMITVectorTRegionCOM listOfRegion = CoTVectorTRegionCOM::Create();
    	TCOMITVectorAnsiStringCOM * listOfRoiTmp;
    	TCOMITRegionCOM * regionTmp;
    	int tailleTableau2;
     
    	tailleTableau = m_listOfRegion.size();
     
    	for(i=0; i<tailleTableau; i++)
    	{
    		listOfRoiTmp = new TCOMITVectorAnsiStringCOM;
    		*listOfRoiTmp = CoTVectorAnsiStringCOM::Create();
    		regionTmp = new TCOMITRegionCOM;
    		*regionTmp = CoTRegionCOM::Create();
    		tailleTableau2 = m_listOfRegion[i].size();
    		for(j=0; j<tailleTableau2; j++)
    		{
    			(*listOfRoiTmp)->set_element(j, m_listOfRegion[i][j].c_str());
    		}
    		(*regionTmp)->set_list((ITVectorAnsiStringCOM*)*listOfRoiTmp);
    		listOfRegion->set_element(i,(ITRegionCOM*)*regionTmp);
    	}
     
    	//regions 
    	texte = "regions: ";
    	Form1->Memo1->Lines->Add(texte);
     
    	TCOMITRegionsCOM regions = CoTRegionsCOM::Create();
    	regions->set_currentRegion((ITRegionCOM*)region);
    	regions->set_list((ITVectorTRegionCOM*)listOfRegion);
     
     
    	//image 
    	texte = "image: ";
    	Form1->Memo1->Lines->Add(texte);
     
    	TCOMITImageDataCOM imageAEnvoyer = CoTImageDataCOM::Create();
    	imageAEnvoyer->set_iMatrix((ITMatrixIntCOM*)matrice);
    	imageAEnvoyer->set_regions((ITRegionsCOM*)regions);
     
    	/*m_image->set_iMatrix((ITMatrixIntCOM*)matrice);
    	m_image->set_regions((ITRegionsCOM*)regions);*/
     
     
     
    	//on retourne l'interface au client 
    	texte = "on retourne l'interface au client: ";
    	Form1->Memo1->Lines->Add(texte);
     
    	*Value = imageAEnvoyer;	
     
    	texte = "";
    	Form1->Memo1->Lines->Add(texte);
     
    	ITRegionsCOM * regs;
    	(*Value)->get_regions(&regs);
     
    	ITRegionCOM * reg;
    	regs->get_currentRegion(&reg);
     
    	ITVectorAnsiStringCOM * vecStr;
    	reg->get_list(&vecStr);
     
    	int tailleInterfaceVecStr;
    	vecStr->get_taille(&tailleInterfaceVecStr);
     
    	texte = "tailleInterfaceVecStr: ";
    	texte += tailleInterfaceVecStr;  
    	Form1->Memo1->Lines->Add(texte);
     
      }
      catch(Exception &e)
      {
        return Error(e.Message.c_str(), IID_IObjetRun);
      }
      return S_OK;
    };

  11. #11
    Expert éminent
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 397
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 397
    Par défaut
    C'est bizarre, MIDL ne donne aucun warning chez moi même en /W4 (du moins, aucun qui concerne ton code IDL). D'un autre côté, moi je suis sous Visual 2005, alors que tu es sous Borland...
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  12. #12
    Expert éminent
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 397
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 397
    Par défaut
    J'ai vu un truc bizarre aussi dans ton interface ITVectorAnsiStringCOM : Non seulement elle ne peut retourner qu'un seul élément car sa méthode element ne prend aucun paramètre en entrée, mais en plus elle retourne un LPSTR, qui n'est pas un vrai type Automation (il faudrait retourner une BSTR à la place)...
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  13. #13
    Membre éclairé Avatar de sylvain.cool
    Profil pro
    Étudiant
    Inscrit en
    Janvier 2006
    Messages
    242
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Janvier 2006
    Messages : 242
    Par défaut
    J'ai fait ça: échange des éléments par BSTR et mise à jour du fichier idl.

    Mais malheureusement, ça ne change rien.

    IDL:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
     
    [
      uuid(4609E683-0944-4456-A849-66BC6B0AB902),
      version(1.0),
      helpstring("Serveur Library")
     
    ]
    library Serveur
    {
     
      importlib("STDOLE2.TLB");
     
      [
        uuid(7A740506-18A2-4C0B-90AE-A653BBEBDF6F),
        version(1.0),
        helpstring("Dispatch interface for TVectorAnsiStringCOM Object"),
        dual,
        oleautomation
      ]
       interface ITVectorAnsiStringCOM: IDispatch
      {
        [
        propget,
        id(0x000000C9)
        ]
        HRESULT _stdcall taille([out, retval] int * Value );
        [
        propput,
        id(0x000000C9)
        ]
        HRESULT _stdcall taille([in] int Value );
        [
        propget,
        id(0x000000CA)
        ]
        HRESULT _stdcall element([in] int Position, [out, retval] BSTR * Value );
        [
        propput,
        id(0x000000CA)
        ]
        HRESULT _stdcall element([in] int Position, [in] BSTR Value );
      };
     
      [
        uuid(66FBB4CE-E85C-420D-8765-0734A7D386F8),
        version(1.0),
        helpstring("TVectorAnsiStringCOM Object")
      ]
      coclass TVectorAnsiStringCOM
      {
        [default] interface ITVectorAnsiStringCOM;
      };
     
      [
        uuid(9AED97B7-9A5D-49E5-BEEB-BF4444C8D115), 
        version(1.0), 
        helpstring("TRegionCOM Object")
      ]
      coclass TRegionCOM
      {
        [default] interface ITRegionCOM;
      };
     
      [
        uuid(8D3A6B08-9B14-41A3-8CEC-E825C7BD37EC), 
        version(1.0), 
        helpstring("TVectorTRegionCOM Object")
      ]
      coclass TVectorTRegionCOM
      {
        [default] interface ITVectorTRegionCOM;
      };
     
      [
        uuid(9C50EC1B-D8A2-4B34-86CF-D1206E18AFF6),
        version(1.0), 
        helpstring("TRegionsCOM Object")
      ]
      coclass TRegionsCOM
      {
        [default] interface ITRegionsCOM;
      };
     
      [
        uuid(89C82050-025D-4B17-BD70-7D1FA2B22A7B), 
        version(1.0), 
        helpstring("Dispatch interface for TMatrixIntCOM Object"), 
        dual, 
        oleautomation
      ]
       interface ITMatrixIntCOM: IDispatch
      {
        [
        propget, 
        id(0x000000C9)
        ]
        HRESULT _stdcall nRows([out, retval] int * Value );
        [
        propput, 
        id(0x000000C9)
        ]
        HRESULT _stdcall nRows([in] int Value );
        [
        propget, 
        id(0x000000CA)
        ]
        HRESULT _stdcall nCols([out, retval] int * Value );
        [
        propput, 
        id(0x000000CA)
        ]
        HRESULT _stdcall nCols([in] int Value );
        [
        propget, 
        id(0x000000CB)
        ]
        HRESULT _stdcall roiBottom([out, retval] int * Value );
        [
        propput, 
        id(0x000000CB)
        ]
        HRESULT _stdcall roiBottom([in] int Value );
        [
        propget, 
        id(0x000000CC)
        ]
        HRESULT _stdcall roiTop([out, retval] int * Value );
        [
        propput, 
        id(0x000000CC)
        ]
        HRESULT _stdcall roiTop([in] int Value );
        [
        propget, 
        id(0x000000CD)
        ]
        HRESULT _stdcall roiLeft([out, retval] int * Value );
        [
        propput, 
        id(0x000000CD)
        ]
        HRESULT _stdcall roiLeft([in] int Value );
        [
        propget, 
        id(0x000000CE)
        ]
        HRESULT _stdcall roiRight([out, retval] int * Value );
        [
        propput, 
        id(0x000000CE)
        ]
        HRESULT _stdcall roiRight([in] int Value );
        [
        propget, 
        id(0x000000CF)
        ]
        HRESULT _stdcall data([out, retval] SAFEARRAY(int) * Value );
        [
        propput, 
        id(0x000000CF)
        ]
        HRESULT _stdcall data([in] SAFEARRAY(int) Value );
      };
     
      [
        uuid(FB282122-08D4-45D0-82B5-3B8863AAA0D3), 
        version(1.0), 
        helpstring("TMatrixIntCOM Object")
      ]
      coclass TMatrixIntCOM
      {
        [default] interface ITMatrixIntCOM;
      };
     
      [
        uuid(75F1C8A2-3437-412A-9425-4E2C25D18D59), 
        version(1.0), 
        helpstring("TImageDataCOM Object")
      ]
      coclass TImageDataCOM
      {
        [default] interface ITImageDataCOM;
      };
     
      [
        uuid(B7A98524-34F9-42AC-B06B-A86AC1B15456), 
        version(1.0), 
        helpstring("ObjetRun Object")
      ]
      coclass ObjetRun
      {
        [default] interface IObjetRun;
      };
     
      [
        uuid(55C7EBA9-2F62-4EA9-903F-E6AD22990DE6), 
        version(1.0), 
        helpstring("Dispatch interface for TRegionCOM Object"), 
        dual, 
        oleautomation
      ]
       interface ITRegionCOM: IDispatch
      {
        [
        propget, 
        id(0x000000C9)
        ]
        HRESULT _stdcall list([out, retval] ITVectorAnsiStringCOM ** Value /*Warning: unable to validate structure name: */ );
        [
        propput, 
        id(0x000000C9)
        ]
        HRESULT _stdcall list([in] ITVectorAnsiStringCOM * Value /*Warning: unable to validate structure name: */ );
      };
     
      [
        uuid(9155E9D1-BA6C-4FCD-8EB4-CDA6273EF83C), 
        version(1.0),
        helpstring("Dispatch interface for TVectorTRegionCOM Object"), 
        dual, 
        oleautomation
      ]
       interface ITVectorTRegionCOM: IDispatch
      {
        [
        propget, 
        id(0x000000C9)
        ]
        HRESULT _stdcall taille([out, retval] int * Value );
        [
        propput, 
        id(0x000000C9)
        ]
        HRESULT _stdcall taille([in] int Value );
        [
        propget, 
        id(0x000000CA)
        ]
        HRESULT _stdcall element([in] int Position, [out, retval] ITRegionCOM ** Value /*Warning: unable to validate structure name: */ );
        [
        propput, 
        id(0x000000CA)
        ]
        HRESULT _stdcall element([in] int Position, [in] ITRegionCOM * Value /*Warning: unable to validate structure name: */ );
      };
     
      [
        uuid(377D91AB-1D3D-4286-98B3-98B0ABD20EA6), 
        version(1.0), 
        helpstring("Dispatch interface for TRegionsCOM Object"), 
        dual, 
        oleautomation
      ]
       interface ITRegionsCOM: IDispatch
      {
        [
        propget, 
        id(0x000000C9)
        ]
        HRESULT _stdcall list([out, retval] ITVectorTRegionCOM ** Value /*Warning: unable to validate structure name: */ );
        [
        propput, 
        id(0x000000C9)
        ]
        HRESULT _stdcall list([in] ITVectorTRegionCOM * Value /*Warning: unable to validate structure name: */ );
        [
        propget, 
        id(0x000000CA)
        ]
        HRESULT _stdcall currentRegion([out, retval] ITRegionCOM ** Value /*Warning: unable to validate structure name: */ );
        [
        propput, 
        id(0x000000CA)
        ]
        HRESULT _stdcall currentRegion([in] ITRegionCOM * Value /*Warning: unable to validate structure name: */ );
      };
     
      [
        uuid(9C3F32A0-DE0A-4AF7-B213-C0D86C875D8C), 
        version(1.0), 
        helpstring("Dispatch interface for TImageDataCOM Object"), 
        dual,
        oleautomation
      ]
       interface ITImageDataCOM: IDispatch
      {
        [
        propget, 
        id(0x000000C9)
        ]
        HRESULT _stdcall regions([out, retval] ITRegionsCOM ** Value /*Warning: unable to validate structure name: */ );
        [
        propput, 
        id(0x000000C9)
        ]
        HRESULT _stdcall regions([in] ITRegionsCOM * Value /*Warning: unable to validate structure name: */ );
        [
        propget, 
        id(0x000000CA)
        ]
        HRESULT _stdcall iMatrix([out, retval] ITMatrixIntCOM ** Value /*Warning: unable to validate structure name: */ );
        [
        propput, 
        id(0x000000CA)
        ]
        HRESULT _stdcall iMatrix([in] ITMatrixIntCOM * Value /*Warning: unable to validate structure name: */ );
      };
     
      [
        uuid(4F779284-3F7E-4DC8-A418-7DDC2912F75F), 
        version(1.0), 
        helpstring("Dispatch interface for ObjetRun Object"), 
        dual, 
        oleautomation
      ]
       interface IObjetRun: IDispatch
      {
        [
        propget, 
        id(0x000000C9)
        ]
        HRESULT _stdcall image([out, retval] ITImageDataCOM ** Value /*Warning: unable to validate structure name: */ );
        [
        propput, 
        id(0x000000C9)
        ]
        HRESULT _stdcall image([in] ITImageDataCOM * Value /*Warning: unable to validate structure name: */ );
        [
        id(0x000000CA)
        ]
        HRESULT _stdcall run( void );
      };
     
    };

  14. #14
    Membre éclairé Avatar de sylvain.cool
    Profil pro
    Étudiant
    Inscrit en
    Janvier 2006
    Messages
    242
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Janvier 2006
    Messages : 242
    Par défaut
    Ça ne viendrait pas de la manière dont je créé mon objet avec des interfaces?

    Parce que mon serveur se termine avec des erreurs (0xC0000005).

    Création des interfaces:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
     
    		//----------------------------------------------------------------------
    		// Création de l'interface
    		//----------------------------------------------------------------------
    		//matrice
    		TCOMITMatrixIntCOM matrice = CoTMatrixIntCOM::Create();
     
    		matrice->set_nRows(m_nRows); 
    		matrice->set_nCols(m_nCols);
    		matrice->set_roiTop(m_roiTop);
    		matrice->set_roiBottom(m_roiBottom);
    		matrice->set_roiLeft(m_roiLeft);
    		matrice->set_roiRight(m_roiRight);
     
    		LPSAFEARRAY lpsa;
    		long Position,Valeur;
    		int tailleTableau = m_data.size();
     
    		lpsa = SafeArrayCreateVector(sizeof(int), 0, m_data.size());
     
    		for(i=0; i<tailleTableau; i++)
    		{
    			Position = i;
    			Valeur = m_data[i];
    			SafeArrayPutElement(lpsa, &Position, &Valeur);
    		}
     
    		matrice->set_data(lpsa);
     
     
    		//currentRegion
    		TCOMITVectorAnsiStringCOM listOfRoi = CoTVectorAnsiStringCOM::Create();
    		tailleTableau = m_listOfRoi.size();
    		WideString strTmp;
    		for(i=0; i<tailleTableau; i++)
    		{        
    			strTmp = m_listOfRoi[i].c_str();
    			listOfRoi->set_element(i, strTmp.c_bstr());
    		}
     
    		TCOMITRegionCOM region = CoTRegionCOM::Create();
    		region->set_list((ITVectorAnsiStringCOM*)listOfRoi);
     
    		//listOfRegion
    		TCOMITVectorTRegionCOM listOfRegion = CoTVectorTRegionCOM::Create();
    		TCOMITVectorAnsiStringCOM * listOfRoiTmp;
    		TCOMITRegionCOM * regionTmp;
    		int tailleTableau2;
     
    		tailleTableau = m_listOfRegion.size();
     
    		//pour ttes les regions
    		for(i=0; i<tailleTableau; i++)
    		{
    			// creation d'une interface liste de roi 
    			listOfRoiTmp = new TCOMITVectorAnsiStringCOM;
    			*listOfRoiTmp = CoTVectorAnsiStringCOM::Create();
     
    			// creation d'une interface region
    			regionTmp = new TCOMITRegionCOM;
    			*regionTmp = CoTRegionCOM::Create();
     
    			//pour toute les rois d'une region
    			tailleTableau2 = m_listOfRegion[i].size();
    			for(j=0; j<tailleTableau2; j++)
    			{        
    				//on met une roi ds l'interface 
    				strTmp = m_listOfRegion[i][j].c_str();
    				(*listOfRoiTmp)->set_element(j, strTmp.c_bstr());
    			}
     
    			//on met les rois ds la region
    			(*regionTmp)->set_list((ITVectorAnsiStringCOM*)*listOfRoiTmp);
    			listOfRegion->set_element(i,(ITRegionCOM*)*regionTmp);
    		}
     
    		//regions
    		TCOMITRegionsCOM regions = CoTRegionsCOM::Create();
    		regions->set_currentRegion((ITRegionCOM*)region);
    		regions->set_list((ITVectorTRegionCOM*)listOfRegion);
     
     
    		//image
    		TCOMITImageDataCOM image = CoTImageDataCOM::Create();
    		image->set_iMatrix((ITMatrixIntCOM*)matrice);
    		image->set_regions((ITRegionsCOM*)regions);

  15. #15
    Expert éminent
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 397
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 397
    Par défaut
    Eh bien déjà, quand je vois un cast C-Style de pointeur, ça me fait peur.
    Par contre, je ne connais pas assez Borland pour t'aider.
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  16. #16
    Membre éclairé Avatar de sylvain.cool
    Profil pro
    Étudiant
    Inscrit en
    Janvier 2006
    Messages
    242
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Janvier 2006
    Messages : 242
    Par défaut
    Oki, donc je dois faire un cast c++.
    Mais lequel?

    Je comprend pas trop la différence entre les 4 (reinterpret, dynamic, static et const).

    Dans mon cas, seul le static_cast passe la compilation... mais ça ne change rien.

  17. #17
    Expert éminent
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 397
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 397
    Par défaut
    Le fait qu'un static_cast passe me rassure. Si ça nécessitait un autre type (moins restrictif) de cast, ça aurait été très suspect.
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  18. #18
    Membre éclairé Avatar de sylvain.cool
    Profil pro
    Étudiant
    Inscrit en
    Janvier 2006
    Messages
    242
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Janvier 2006
    Messages : 242
    Par défaut
    Bon, mon problème n'est pas résolu, mais je l'ai détourné.

    Je n'ai plus de propriété image sur "objetRun".

    Mais la méthode "run" prend l'image en in ET out.

    De cette façon, je peux la modifier et la renvoyée.

    Merci encore pour ton aide Medinoc.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Problème de retour à la ligne
    Par AurelBUD dans le forum Général JavaScript
    Réponses: 20
    Dernier message: 30/05/2006, 15h17
  2. show_hide un div: problème avec retour
    Par -DeN- dans le forum Général JavaScript
    Réponses: 4
    Dernier message: 17/02/2006, 12h16
  3. Problème de retour aprés l'appel d'une popup
    Par PADAWANN33 dans le forum Général JavaScript
    Réponses: 4
    Dernier message: 06/02/2006, 15h53
  4. [MySQL] problème de retour à la ligne.
    Par NPortmann dans le forum PHP & Base de données
    Réponses: 2
    Dernier message: 29/09/2005, 14h43
  5. [Struts] Problème de retour chariot
    Par pimousse76 dans le forum Struts 1
    Réponses: 5
    Dernier message: 22/11/2004, 15h39

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo