I followed this tutorial "https://github.com/Redth/ZXing.Net.Mobile" when I use Live Preview and pair it with my android device and try to hit scan button the code breaks and it gives error like "Exception of type 'System.Collections.Generic.KeyNotFoundException' was thrown".
The error is thrown on very first line.
var scanPage = new ZXingScannerPage();
I 'm new to this one and not sure how to solve, if possible please let me know any barcode code which reads as well as scan in Visual studio 2017.
So I have checked in the github as well, its clear from forum that live preview has issues related to System.Collections.Generic.KeyNotFoundException so either have device connected or install some emulator and check.
Related
I want to send users who press a button in my Uno Platform (Xamarin) Android mobile app to a pre-populated email with the body and subject passed as a parameter, so as to automate the process of sending a report.
The app uses the MVVM pattern, the button in the View is bound to a command in the ViewModel which puts together some strings and tries to send them along with the user to their email app of choice. Nothing overtly complex.
Since Android 13 the following piece of code causes the app to consistently crash (which it didn't do earlier)
var message = new Xamarin.Essentials.EmailMessage
{
Subject = Report.SUBJECT,
Body = Report.DATA
To = new List<string> { Report.RECIPIENT }, // "example#example.com"
};
await Xamarin.Essentials.Email.ComposeAsync(message);
Stack trace yields the following
ApplicationActivity+<>c__DisplayClass29_0.<SetContentView>b__0 (System.Object s, Android.Views.View+ViewAttachedToWindowEventArgs e)
System.NullReferenceException: Object reference not set to an instance of an object
which is weird. The message is not null (seen in the debugger). Also, despite the app crashing, the message itself is correctly generated in the chosen email app (if I navigate there manually after my app crashed, that is)
Minimum Android version for the app is Android 9 (API level 28), target is 11 (API 30).
The newest .NET Core SDK is 6.0.101, and .NET Core Runtime is 6.0.1, as seen in the SDK manager.
I'm working in Visual Studio 2019 for Mac community edition version 8.10.22 (build 11)
How do I deal with this?
What I tried so far:
Replacing ComposeAsync with Launcher.OpenAsync results in the same failure.
var uri = $"mailto:{Report.RECIPIENT}?subject={Report.SUBJECT}&body={Report.DATA}";
await Xamarin.Essentials.Launcher.OpenAsync(uri);
In fact, even just going to some example website turns out to crash in the same way
var uri = "https://example.com";
await Xamarin.Essentials.Launcher.OpenAsync(uri);
Wrapping the whole method (regardless of launcher or email) in a try-catch statement fails to catch anything and app crashes nonetheless
private async void SendReport()
{
try
{
// Do the thing
}
catch (Exception ex)
{
// Some exception occurred
}
}
Elsewhere in the app, using a hyperlink button in the View (instead of a ViewModel method) surprisingly does work normally
<HyperlinkButton
NavigateUri="mailto:example#example.com">
<TextBlock Text="Contact via e-mail"/>
</HyperlinkButton>
which suggests that it is Xamarin.Essentials that isn't working for me, not just emails in Android.
I would much prefer solving the issue in the SendReport method in the ViewModel instead of resorting to that one weird trick that programmers hate (of switching to a hyperlink button in UI) to make it work.
Documentation about Android 13 behaviour changes to all apps doesn't seem to contain any changes of obvious relevance to this issue.
iOS in contrast works fine this time
This desperate attempt didn't work out of the box.
System.Diagnostics.Process.Start("http://www.c-sharpcorner.com/Default.aspx");
My environment is quite fragile which is why I'm highly hesitant to try updating anything as a rule
I have a mobile app in Xamarin where a QR-code scanner is needed. Scanning the code works fine... After scanning a code, the user is redirected to another page. After checking out this page, the user is redirected to the page where the scanner is located. So, when this redirection happens, I get the error Java.Lang.RuntimeException: 'getParameters failed (empty parameters)'... I googled for hours but couldn't find any solution for this problem. BTW, it also happens when I use the 'back' button on the emulator or real word Android device...
--SOLVED--
Changing the PushAsync(pageX()) to PopAsync(); worked in my case. Found out that the problem is bases around getting the camera parameters. These are not available, because the camera is already using it in the former screen. So closing the camera/ending the camera activity is also a solution!
Used the following link:
https://learn.microsoft.com/en-us/azure/cognitive-services/cognitive-services-apis-create-account?tabs=singleservice%2Cunix
to Create a Cognitive Services resource.
Then used:https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/get-started-speech-to-text?tabs=windowsinstall&pivots=programming-language-csharp
to get the code example to recognize from a microphone.
Included the Microsoft.CognitiveServices.Speech.Audio as NuGetPackae and everything worked fine on windows 10 with vs 2019.
Pushed the project up to GitHub and downloaded it onto my macBook and nothing is happening....No errors....nothing in call stack nothing...(apart from a message in the threads about cancelation token? but im not sure if this is an error or not??..when I say nothing is happening..the code runs and displays "Speak into your microphone" in the terminal...then after one second it closes and program ends
Does anyone know why it isnt working or what I can do to further test it. thanks
also to note microphone is working on macbook, have tested this, thanks
UPDATE
Have followed the instructions from:
https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/master/quickstart/csharp/dotnetcore/from-microphone
and still not working...
the problem is (please see two below images)
var result = await recognizer.RecognizeOnceAsync();
result.Text is returning "Hello how are you" in windows 10 with VS 2019,
however in BigSur 11.6 macbook with VS 2019 8.10.11 (build 8) it is returning "" does anyone know why? I cant understand why ios is returning 'NoMatch"
I'm trying to use this MediaCapture API sample:
https://code.msdn.microsoft.com/windowsapps/Media-Capture-Sample-adf87622
but when I press Start Record to record to a file, this line never returns:
await m_mediaCaptureMgr.StartRecordToStorageFileAsync(recordProfile, m_recordStorageFile);
And no error is thrown. This computer is a Cyberpower PC. The sample DOES work on my other windows 10 computer (a mac mini) though. I thought maybe it was a codec issue but can't find any information on installing codecs so maybe that is not it--not sure. Thank you for any help or information.
Additional Info: Creating a profile like this works:
MediaEncodingProfile recordProfile = null;
recordProfile = MediaEncodingProfile.CreateWmv(Windows.Media.MediaProperties.VideoEncodingQuality.Auto);
But calling CreateMp4 instead of CreateWmv does not work.
My suspicion is that there's something wrong with your particular installation's encoders. If you can upgrade to Windows 10, with Visual Studio 2015 you can develop universal apps. The same code should work without an issue.
I am the beginner on window 8 store app,still i am working on the app in which i have to open camera and capture the image, but when i try to execute following line of code, its throws following exception.
I am using following line of code
Windows.Media.Capture.CameraCaptureUI dialog = new CameraCaptureUI();
And throwing following exception
Requested Windows Runtime type 'Windows.Media.Capture.CameraCaptureUI' is not registered.
Please advise
thanks in advance
Maybe because you are on an emulator? Can you reproduce the error on a real device?