2013-06-18 3 views
0

Dans mon application Im essayant d'appeler une fonction de classe ATL COM à partir de mon application WPF. Les paramètres de fucntion de la classe ATL COM sont comme ceci.Convertir double [,] en Variant *

[id(5)] HRESULT GetFormationZPoints([in] BSTR sLyrName, [in,out] VARIANT* pLandingPoints); 

Et côté WPF, je suis en train de passer comme ça

List<PointsVector> landingPoints = Planner.LandingPointsList; 
double[,] dLPs = new double[landingPoints.Count, 3]; 
int i = 0; 
foreach (PointsVector v in landingPoints) 
{ 
    dLPs[i, 0] = v.X; 
    dLPs[i, 1] = v.Y; 
    dLPs[i, 2] = v.Z; 
    i++; 
} 
gaInfo.GetFormationZPoints(targetReservoir.TargetLayerName, ref dLPs); 

d'un double tableau de 2-D Je reçois le message d'erreur suivant. "Argument 2: impossible de convertir à partir de 'ref double [,]' à 'objet ref"

Quelqu'un peut-il vous aider s'il vous plaît. Un grand merci à l'avance.

Répondre

1

Comme mentionné dans l'exception, pouvez-vous convertir la variable dLPs en objet et voir si cela fonctionne. Fondamentalement, il devrait ressembler à quelque chose comme,

gaInfo.GetFormationZPoints(targetReservoir.TargetLayerName, ref (object) dLPs); 
+0

J'ai essayé ceci, mais cela ne compile pas. Donne un message d'erreur "paramètre ref ou out doit être une valeur assignable". J'ai donc essayé ceci objet obj = (objet) dLPs; gaInfo.GetFormationZPoints (targetReservoir.TargetLayerName, ref obj); Donc, cela fonctionne très bien. Merci beaucoup pour l'aide mec :) – WAQ