Unknown crashes happening for Invalid Cast Exception "TappedRoutedEventArgs" -> "FrameworkElement" - windows

Specified cast is not valid.","stack_trace":"System InvalidCastException: Unable to cast object of type 'Windows UI Xaml Input TappedRoutedEventArgs' to type 'Windows UI Xaml FrameworkElement' at GalaSoft MvvmLight Command RelayCommand`1 Execute(Object parameter) at Microsoft Xaml Interactions Core InvokeCommandAction Execute(Object sender Object parameter) at Microsoft Xaml Interactivity Interaction ExecuteActions(Object sender ActionCollection actions Object parameter) at Microsoft Xaml Interactions Core EventTriggerBehavior OnEvent(Object sender Object eventArgs
I have been getting a lot of this exception for my Windows Phone Store App from the store crash report.But not able to figure out the issue.Please help.

Related

Visual Studio App Center Analytics Not working for Xamarin Forms Android Project

I am using Visual Studio App Center for my Xamarin Forms Android Application for capturing the Analytics(Events and Crashes)
I am configuring crashes and analytics in OnStart of my App.Xaml.cs
AppCenter.Start($"android={Settings.Current.AppCenterAnalyticsAndroid};" +
typeof(Analytics), typeof(Crashes));
And for invoking the Events I am calling the below Method.
public void TrackEvent(string name, Dictionary<string, string> properties = null)
{
Analytics.SetEnabledAsync(true).ConfigureAwait(false);
Analytics.TrackEvent(name, properties);
}
Crashes are logging correctly in App Center But the events are not.
Also I can see the corresponding entries in Log Flow
Your app secret string is invalid because it contains + typeof(Analytics), it should be , typeof(Analytics).
Since you used the android key/value delimiter we could extract the appSecret and make it work with Crashes, but typeof(Analytics) ended up in the wrong appSecret parameter string.
You shouldn't need to add Analytics.SetEnabledAsync(true).ConfigureAwait(false);
Simply Call Analytics.TrackEvent(name, properties); (it doesn't need to be in a task anyways. I track my events in the Construtor of pages, for example.
Also, when you run the application, you get a debug Message confirming that AppCenter has been configured correctly, check if that is the case.
And, it may take a while, for them to appear in the Events.

Outlook VSTO form does not display in release version (installed)

Thanks for looking.
I am working on an Outlook plugin that includes a pop-up Form that loads a browser inside of it to allow the user to log in via a 3rd party auth service.
This works great when running from a debug session: I see the custom tab in the ribbon, click the "login" button, and the form pops up as a modal using .ShowDialog().
I am using Outlook 2016.
Problem
When I publish this VSTO and then install it on my machine, the plugin loads and I can see the "login" button in the custom ribbon tab, but clicking it does nothing. I have checked to be sure that the dialog isn't simply popping under the main form. If it's there--I can't find it.
Back to debug session--everything works great. I suspect a permissions issue, but I don't get any prompts or errors from Outlook.
Last, I don't know if it's related, but I sent the VSTO installer to a colleague and they get the following error when attempting to install:
System.Security.SecurityException: Customized functionality in this
application will not work because the certificate used to sign the
deployment manifest for {APP NAME REMOVED} or its location is not
trusted. Contact your administrator for further assistance.
Any help is greatly appreciated.
Most probably your form is shown behind the Outlook window. You need to specify the parent window handle if you want to see the form all the time on top of Outlook windows. The Show and ShowDialog methods of the System.Windows.Forms.Form class allows to specify the parent window handle by passing an instance of the IWin32Window interface as a parameter.
First, you need a class which implements that interface:
public class WindowWrapper : System.Windows.Forms.IWin32Window
{
public WindowWrapper(IntPtr handle)
{
_hwnd = handle;
}
public IntPtr Handle
{
get
{
return _hwnd;
}
}
private IntPtr _hwnd;
}
In Outlook you can cast an instance of the Explorer or Inspector class to the IOleWindow interface and get the window handle which can be used for the IWin32Window implementation.

session state service failed prism (Windows store app)

I am trying to react to suspend events within my Windows Store App. I added the appropriate callback method, but I've run into a problem:
App.Current.Suspending += Current_Suspending;
void Current_Suspending(object sender, Windows.ApplicationModel.SuspendingEventArgs e){}
The problem is that, when I trigger the suspension event in Visual Studio and the callback method is called (I have checked it with a breakpoint), it immediately terminates with an Exception:
session state service failed.
Any suggestions on how to solve this problem?
If you are using Prism as I was this can happen when the SessionStateService chokes on serializing an object. Relevant navigation parameters and anything manually added get serialized at app termination or suspension. In my specific case i had a non-nullable enum that wasn't being set on an object used as a navigation parameter. I used the following to verify the DataContractSerializer wasn't having issues with object.
test.Add("testitem", new WorkflowStep());
MemoryStream sessionData = new MemoryStream();
DataContractSerializer serializer = new DataContractSerializer(typeof(Dictionary<string, object>));
serializer.WriteObject(sessionData, test);

MvvmLight's SimpleIoc breaking in Xamarin Forms 1.3 Android and iOS app, but not in Windows Phone

I am working on a Xamarin Forms app and all is going well with the Windows Phone building and running. However when I try and run the Android version, it build OK and then fails and I get an exception when calling the ServiceLocator to resolve ViewModel in the ViewModelLocator.
Breaks on the line in the ViewModelLocator
return ServiceLocator.Current.GetInstance<MainViewModel>();
with
System.Reflection.TargetInvocationException
Source "mscorlib" string
StackTrace "at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Bind…"
and hovering over the 'GetInstance' shows
Could not resolve type: global::Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance<global::hms.BillSplitter.ViewModel.PCL.MainViewModel>
My ViewModel's only constructor looks like
public MainViewModel(INavigationService navigationService, ICountryTippingService countryTippingService, AppSettings appSettings)
{
_navigationService = navigationService;
_countryTippingService = countryTippingService;
ThisAppSettings = appSettings;
ThisBillDetail = new BillDetail();
ThisBillDetail.TotalOnBill = 0;
}
All dependencies are registered ahead of this in the ViewModelLocator e.g.
SimpleIoc.Default.Register(() => new HmsPublicCoreMobileServiceClient(HmsCommonSettingConstants.HmsPublicCoreServiceUrl, HmsCommonSettingConstants.HmsPublicCoreServiceAppKey));
var prefService = ServiceLocator.Current.GetInstance<IPreferenceService>();
SimpleIoc.Default.Register(() => (SettingsHelper.GetCurrentSettings(prefService)));
SimpleIoc.Default.Register<MainViewModel>();
and some platform specific ones in the MainActivity.cs (Android) and AppDelegate(iOS) e.g.
SimpleIoc.Default.Register(() => new PreferenceService(this));
What I don't get is that it work beautifully in Windows Phone? What is it about Android that's different? Has anyone used SimpleIoc in Xamarin 1.3+?
Should I use a factory to create he ViewModel?
Any help would be great and much appreciated. I am using all the latest versions for MVVMLight (5.1.0.1) and Xamarin (1.3.3).
I finally worked out what the problem was and it's pretty basic and nothing to do with MvvmLight and/or Xamarin Forms updates!
I made the mistake of Registering a concrete class in a factory and then attempted to GetInstance on an Interface. SimpleIoC was not able to reconcile it.
from the code above
SimpleIoc.Default.Register(() => (SettingsHelper.GetCurrentSettings(prefService)));
should have been
SimpleIoc.Default.Register<IPreferenceService>(() => (SettingsHelper.GetCurrentSettings(prefService)));
so that the line
var prefService = ServiceLocator.Current.GetInstance<IPreferenceService>();
would know what I was talking about.
Anyhow, if you get errors like this, you'll know what to look for!!

PROBLEM :An error message cannot be displayed because an optional resource assembly containing it cannot be found

I created Windows Mobile Application and I loaded web service that contain one method (GetNumber). When I call this method from my emulator I got a following exception
An error message cannot be displayed because an optional resource assembly containing it cannot be found.
Can anyone help me. This is my code from WM Application, it is very siple.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MobileClientApp;
namespace MobileClientApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MobileClientApp.localhost.WebService m = new MobileClientApp.localhost.WebService();
int result;
bool resbool;
m.GetNumber(10, true, out result, out resbool);
label1.Text = result.ToString();
}
}
}
For a very good explanation:
http://blogs.msdn.com/b/netcfteam/archive/2004/08/06/210232.aspx
(excerpt from above)
There has been some confusion about the error message: "Could not find resource assembly". Basically, this means that there is some exception that has happened in the program. The error did not happen because it could not find the resource assembly. The resource assembly that it is searching for contains exception messages (strings) that would be helpful in debugging what went wrong with the program.
Since the user is never expected to see this error message if the program works as expected and all exceptions are handled appropriately, it was decided (due to size constraints) that the resource assembly that has these error strings are never put on a user's device. Thus the main target audience of these error strings are developers who would like to debug issues. Hence, when you do an F5 deploy onto the device, the System.SR.dll assembly which have these error strings are copied to the device and the developer can see the error messages. But in case .Net Compact Framework is installed from a redistributable or you are using .Net Compact Framework that come with the device (as a user of the device would be doing), the System.SR.dll is not present on the device. Hence, if the application did come upon an exceptional condition that wasn't handled by the application, this "Could not find resource assembly" message would be shown to the user.
If you are not using Visual Studio F5 deploy to the device and would still like to see the exception messages, you can achieve this by taking the System_SR_[Language].CAB where [Language] corresponds to the language in which you want to see the error message to appear and clicking on the cab file to install it
Sounds like you are missing an assembly in your deployment.

Resources