Using CameraButtons in Windows phone 8.1


  • This is my first post - please let me know if it's in the wrong place or any incorrect conventions are used.

     I'm trying to write simple windows phone camera app. I'm using Windows server 2012R2, Visual Studio 2013 community edition (Update 4) with all options installed and a nokia lumia 520 as a test device. All in C#. I'm a C++ programmer of many years with some c#. I can't get access to the camera buttons object. I get the error 

    1>C:\Program Files (x86)\MSBuild\Microsoft\WindowsXaml\v12.0\8.1\Microsoft.Windows.UI.Xaml.Common.targets(327,9): Xaml Internal Error error WMC9999: Cannot find type System.SystemException in module mscorlib.dll 

    during compilation.

    These are the steps to reproduce :
    1) Create a new project c# > Store Apps > Windows Phone Apps > Blank App
    2) Open App.xaml.cs and add "using Microsoft.Devices;". This is rejected with the error  "The type or namespace name 'Devices' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)"
    3) Open the object browser, in the Browse drop down box I select "Windows Phone 8.1" (The first of them, there are, oddly, three identicle entries) and in the search box I put "CameraButtons". This gives a single result, the class Microsoft.Devices.CameraButtons.
    4) I press the clear search button and the objects pane shows me the location of the class in the container Microsoft.Phone(C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\WindowsPhone\v8.1\Microsoft.Phone.dll), namespace Microsoft.Devices.
    5) I click the "Add to references in selected project in solution explorer" button. I now have the following references in the project : .NET for windows store apps, Microsoft.Phone and Windows Phone 8.1.
    6) I return to App.xaml.css to see my "using Microsoft.Devices;" directive has been accepted.
    7) I add the following code to my Application class :
            private void stuff()
            private void CameraButtons_ShutterKeyPressed(object sender, EventArgs e)
    8) I build and get the following error : 1>C:\Program Files (x86)\MSBuild\Microsoft\WindowsXaml\v12.0\8.1\Microsoft.Windows.UI.Xaml.Common.targets(327,9): Xaml Internal Error error WMC9999: Cannot find type System.SystemException in module mscorlib.dll.

    Help appreciated.

    Wednesday, March 04, 2015 7:10 AM


All replies

  • Microsoft.Devices is a Silverlight Library. The issues you are seeing are due to using a Silverlight library in a WinRT project. I have not been able to find an article outlining how to access the hardware shutter from WinRT projects and therefore believe that it's currently not supported.

    You could retarget your App towards Silverlight 8.1 (which would still support the new Windows.Media.Capture API) and in addition to the Button support what also add the ability to integrate with the Lenses feature which to my knowledge is currently also limited to Silverlight Apps.

    Wednesday, March 04, 2015 11:51 AM
  • Thank you for the pointer, I've created a Silverlight project and I'm trying to adapt the code for the MediaCapture object but there is no Windows.UI.Xaml.CDontrols.CaptureElement in silverlight and without MediaCapture being set as a source for something, StartPreviewAsync fails. My previous experiments indicate that MediaCapture cannot take a photo unless it is previewing. 
    Wednesday, March 04, 2015 4:15 PM
  • This article shows how to do a video preview using Windows.Media.Capture in a Silverlight App: https://msdn.microsoft.com/en-us/library/windows/apps/dn655126%28v=vs.105%29.aspx?f=255&MSPPError=-2147217396
    Wednesday, March 04, 2015 6:03 PM
  • Many Thanks - I think you've pointed me in the right direction.


    Saturday, March 07, 2015 10:19 AM