Open anacardix opened 3 months ago
Can you provide a callstack of the exception being thrown in WriteArgs
? (Preferably with both Managed+Native frames)
Would surrounding the call to Launcher.LaunchFileAsync
in a try/catch. And rejecting the promise in the catch fix the issue? Is it the promise Resolve/Reject thats throwing, or something else in Launcher.LaunchFileAsync
?
If the exception is thrown in WriteArgs that generally indicates that you have a function signature mismatch between your JS and your native code.
@anacardix, could you create a project that shows the issue? It would be much easier to repro and debug it.
Can you provide a callstack of the exception being thrown in
WriteArgs
? (Preferably with both Managed+Native frames)Would surrounding the call to
Launcher.LaunchFileAsync
in a try/catch. And rejecting the promise in the catch fix the issue? Is it the promise Resolve/Reject thats throwing, or something else inLauncher.LaunchFileAsync
?If the exception is thrown in WriteArgs that generally indicates that you have a function signature mismatch between your JS and your native code.
Here is the call stack:
Regarding your question about handling exceptions with Launcher.LaunchFileAsync
:
Wrapping the call to Launcher.LaunchFileAsync
in a try/catch block and handling promise rejection in the catch does not resolve the issue, as the exception does not appear to originate from the Launcher.LaunchFileAsync
.
@anacardix, could you create a project that shows the issue? It would be much easier to repro and debug it.
@anacardix Would it be possible to create a standalone repro of this? As is this is hard for us to evaluate. The overall environment is going to affect what's happening here so we need more context.
@anacardix, could you create a project that shows the issue? It would be much easier to repro and debug it.
@anacardix Would it be possible to create a standalone repro of this? As is this is hard for us to evaluate. The overall environment is going to affect what's happening here so we need more context.
Sorry for the delay in responding to your request. I had some difficulty initially in reproducing the error in a standalone project. However, I've now managed to replicate the issue and have pushed the relevant code to my repository on GitHub. You can access the repro project at anacardix/promiseExample.
Problem Description
When handling promises within a React Native Module, specifically using the
CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync
method to launch an application, aSystem.Runtime.InteropServices.SEHException
labeled "External component has thrown an exception." is thrown. This occurs at the methodWriteArgs
ofJSValueWriter
. However, moving the promise resolution outside of theCoreApplication
block resolves the issue.Steps to Reproduce
Launcher.LaunchFileAsync
.Use the following code snippet where the promise is resolved or rejected inside the
CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync
block:Steps To Reproduce
Run the above code
Expected Results
No response
CLI version
12.3.2
Environment
Target Platform Version
10.0.19041
Target Device(s)
Desktop
Visual Studio Version
Visual Studio 2022
Build Configuration
Debug
Snack, code example, screenshot, or link to a repository
No response