2009-08-03 4 views
0

늦은 바운드 COM 개체를 릴리스해야 할 것 같아요.
하지만 어떻게 직접 할 수 있습니까? 내가 구글 어스에서 포커스 포인트를 얻기 위해 C#을에서 다음 코드를 사용하여 내 상황에서늦은 바운드 COM 개체를 해제하는 방법?

(간체) :

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); 

그래서 내가 어떻게 카메라를 출시하고 구글 어스는이 상황에서 개체를?

답변

6

당신은 사용할 수 있습니다 Marshal.ReleaseComObject

예를 들어,

if(Marshal.IsComObject(oGE)==true) 
{ 
    Marshal.ReleaseComObject(oGE); 
} 
관련 문제