Question

Je suppose que je dois également libérer les objets COM liés plus tard.
Mais comment cela se fait-il directement?

Dans ma situation, j'utilise le code suivant de C # pour obtenir le point focal de Google Earth (simplifié):

Type oClassType = Type.GetTypeFromProgID("GoogleEarth.ApplicationGE");
object oGE = Activator.CreateInstance(oClassType);
object oCamera = oGE.GetType().InvokeMember("GetCamera", System.Reflection.BindingFlags.InvokeMethod, null, oGE, new object[] { 0 });
double dFocusLatitude = (double)oCamera.GetType().InvokeMember("FocusPointLatitude", System.Reflection.BindingFlags.GetProperty, null, oCamera, null);
double dFocusLongitude = (double)oCamera.GetType().InvokeMember("FocusPointLongitude", System.Reflection.BindingFlags.GetProperty, null, oCamera, null);

Alors, comment puis-je libérer l'appareil photo et les objets Google Earth dans cette situation?

Était-ce utile?

La solution

Vous pouvez utiliser Marshal.ReleaseComObject

par exemple

if(Marshal.IsComObject(oGE)==true)
{
  Marshal.ReleaseComObject(oGE);
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top