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