none
cannot be added to list of known types since another type RRS feed

  • 问题

  • 当我用程序调用相机的时候,程序就直接跳转到Application_UnhandledException里面,查看错误信息



    InvalidOperationException:
    Type 'System.Object[]' cannot be added to list of known types since another type
    'System.Collections.ObjectModel.Collection`1[System.Object]' with the same data contract name 'http://schemas.microsoft.com/2003/10/Serialization/Arrays:ArrayOfanyType' is already present.

     

     

    在网上查找了一下,这个错误好像在PC上也有 http://support.microsoft.com/kb/967339/ 微软也出了,但是不知道Windows phone 如何解决这个问题?

     

    2011年9月25日 11:32

答案

  • 我用来调用相机的代码如下,暂时未发现您所说的情况。

                        PhotoCamera cam = null;

                        // Check to see if the camera is available on the device.
                        if ((PhotoCamera.IsCameraTypeSupported(CameraType.Primary) == true) ||
                             (PhotoCamera.IsCameraTypeSupported(CameraType.FrontFacing) == true))
                        {
                            // Initialize the camera, when available.
                            if (PhotoCamera.IsCameraTypeSupported(CameraType.FrontFacing))
                            {
                                // Use front-facing camera if available.
                                cam = new Microsoft.Devices.PhotoCamera(CameraType.FrontFacing);
                            }
                            else
                            {
                                // Otherwise, use standard camera on back of device.
                                cam = new Microsoft.Devices.PhotoCamera(CameraType.Primary);
                            }

                            //// Event is fired when the PhotoCamera object has been initialized.
                            //cam.Initialized += new EventHandler<Microsoft.Devices.CameraOperationCompletedEventArgs>(cam_Initialized);

                            //// Event is fired when the capture sequence is complete.
                            //cam.CaptureCompleted += new EventHandler<CameraOperationCompletedEventArgs>(cam_CaptureCompleted);

                            // Event is fired when the capture sequence is complete and an image is available.
                            cam.CaptureImageAvailable += new EventHandler<Microsoft.Devices.ContentReadyEventArgs>(cam_CaptureImageAvailable);

                            // Event is fired when the capture sequence is complete and a thumbnail image is available.
                            cam.CaptureThumbnailAvailable += new EventHandler<ContentReadyEventArgs>(cam_CaptureThumbnailAvailable);

                            //Set the VideoBrush source to the camera.
                            CameraVideoBrushExtensions.SetSource(viewfinderBrush, cam);
                            //viewfinderBrush.SetSource(cam);

                            CameraButtonEnable = true;
                            AppBarModeDefault = true;
                        }


    Cedar
    2011年9月27日 6:34
    版主