Forum Cross Platform with Xamarin

Problem with Xam.Plugin.Media

Hi, first than nothing, I dont speak English very much, so sorry for that.

I'm trying to create a app for take a picture, for now, only that. Well the problem is when i try this, my App closes.. this is my structure:

I have a Button with a Command:

public ICommand takePictureCommand { get { return new RelayCommand(takepikture); } }

And the command does this:

private async void takepikture() {

        await CrossMedia.Current.Initialize();

        if (!CrossMedia.Current.IsCameraAvailable || CrossMedia.Current.IsTakePhotoSupported){
            await Application.Current.MainPage.DisplayAlert("Error", "No se puede acceder a la camara", "OK");
            return;
        }

        var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions(){
            Directory = "Photos",
            Name = "name.jpg"
        });

        if (file != null){
            ImageSource = ImageSource.FromStream(() =>{
                var stream = file.GetStream();
                file.Dispose();
                return stream;
            });
        }

}

When my app is break, throw this:

An unhandled exception occured. occurred

And in the Output show this:

08-23 15:24:18.358 D/[email protected]MainActivity: ViewPostImeInputStage processPointer 0
08-23 15:24:18.470 D/[email protected]MainActivity: ViewPostImeInputStage processPointer 1
08-23 15:24:18.480 D/Mono ( 8900): Assembly Ref addref recursosMoviles[0xdc46f9a0] -> Plugin.Media.Abstractions[0xdc46fa00]: 2
08-23 15:24:18.483 D/Mono ( 8900): Assembly Ref addref recursosMoviles[0xdc46f9a0] -> Plugin.Media[0xdc46fb20]: 2
08-23 15:24:18.483 D/Mono ( 8900): Assembly Ref addref Plugin.Media[0xdc46fb20] -> Plugin.Media.Abstractions[0xdc46fa00]: 3
08-23 15:24:18.484 D/Mono ( 8900): Unloading image System.Threading.Tasks.dll [0xb9218600].
08-23 15:24:18.485 D/Mono ( 8900): Image addref System.Threading.Tasks[0xbb5ce5a0] -> System.Threading.Tasks.dll[0xc8575a00]: 7
08-23 15:24:18.485 D/Mono ( 8900): Config attempting to parse: 'System.Threading.Tasks.dll.config'.
08-23 15:24:18.485 D/Mono ( 8900): Config attempting to parse: '/usr/local/etc/mono/assemblies/System.Threading.Tasks/System.Threading.Tasks.config'.
08-23 15:24:18.485 D/Mono ( 8900): Assembly Ref addref Plugin.Media.Abstractions[0xdc46fa00] -> System.Threading.Tasks[0xc8a6be40]: 5
08-23 15:24:18.488 D/Mono ( 8900): Unloading image System.IO.dll [0xb9214f00].
08-23 15:24:18.492 D/Mono ( 8900): Image addref System.IO[0xbb5ce5a0] -> System.IO.dll[0xc8578200]: 6
08-23 15:24:18.492 D/Mono ( 8900): Config attempting to parse: 'System.IO.dll.config'.
08-23 15:24:18.492 D/Mono ( 8900): Config attempting to parse: '/usr/local/etc/mono/assemblies/System.IO/System.IO.config'.
08-23 15:24:18.492 D/Mono ( 8900): Assembly Ref addref recursosMoviles[0xdc46f9a0] -> System.IO[0xc8a6c440]: 4
InspectorDebugSession(5): HandleTargetEvent: UnhandledException

Please help me, I tried every all and nothing.. I need do this... :(

Sign In or Register to comment.