1

我使用来自http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202956%28v=vs.105%29.aspx的代码, 而

当我按下后退按钮但相机未初始化时出现异常。

Microsoft.Devices.Camera.ni.dll 中发生了“System.ObjectDisposedException”类型的异常,并且在托管/本机边界之前未处理

如何避免异常?问题在于:

 protected override void OnNavigatingFrom(System.Windows.Navigation.NavigatingCancelEventArgs e)
    {
        try
        {
            if (_photoCamera != null )
            {
                // Dispose camera to minimize power consumption and to expedite shutdown.
                _photoCamera.Dispose();                            


                _photoCamera.Initialized -= cam_Initialized;
                _photoCamera.AutoFocusCompleted -= _photoCamera_AutoFocusCompleted;
           }
        }
        catch (Exception)
        {

            throw;
        }

    }
4

0 回答 0