在初始化之前处理相机时出现异常已准备就绪

时间:2013-06-21 13:06:08

标签: windows-phone-7 windows-phone-8

我使用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;
        }

    }

0 个答案:

没有答案