I'm working with USD 4.1.1319 and there are a number places where we open links to custom hosted controls and display certain sites using the old WebBrowser / WebView classes, where then then automate through the pages using context from USD.
I am currently upgrading all of these to WebView2 because WebBrowser has display issues due to old IE compatibility and WebView can't open PDFs. WebView2 fixes both these issues.
Now, I have all my code updated, but when I open these apps and then try to open a new session to display a D365 record (Phone Call specifically) or if I open the session first and THEN the app from the session, it causes USD to crash. No error is thrown, it just closes.
The Phone Call hosted control is using Hosting Type = Chrome; when I switch it to Edge, it **doesn't** crash, but then causes my session to load with a blank D365 interface instead of the expected entity form.
Here is where I am initializing the WebView2 coreasync (this is a portion of the code):
protected override async void DoAction(RequestActionEventArgs args)
{
await webView2.EnsureCoreWebView2Async();
webView2.CoreWebView2.DOMContentLoaded += new EventHandler<CoreWebView2DOMContentLoadedEventArgs>(WebView_NavigationCompleted);
if (args.Action.ToLower() == "opensite")
{
FireEvent("Open");
_common.Log("Site", "DoAction:OpenSite", "Fire event: Site,Open", System.Diagnostics.TraceEventType.Verbose);
}
}
If I remove the "await WebView2.EnsureCoreWebView2Async()" method, it works, but then of course all my other code fails because that's not initialized.
So my questions are:
1) Can I not utilize WebView2 on a USD version below 4.2? I know 4.2 adds WebView2 functionality, but I thought that would be separate from the custom hosted control code.
2) Why do I get a blank page when switching from Chrome > Edge hosting type?
3) Am I not initializing WebView2 correctly?
Please let me know if you need further information!
From the logs, this is the error I am seeing:
Microsoft.Crm.UnifiedServiceDesk.Diagnostics Information 8 07/08/2021 11:56:31 AM FileCollector took: 109 ms
Microsoft.Crm.UnifiedServiceDesk.Diagnostics Information 8 07/08/2021 11:56:31 AM RegistryCollector took: 643 ms
Microsoft.Crm.UnifiedServiceDesk.Diagnostics Information 8 07/08/2021 11:56:36 AM MachineSnapshotCollector took: 5087 ms
Microsoft.Crm.UnifiedServiceDesk.Diagnostics Information 8 07/08/2021 11:56:39 AM EventLogCollector took: 8757 ms
Microsoft.Crm.UnifiedServiceDesk.Diagnostics Information 8 07/08/2021 11:56:39 AM Exit CollectExitReports
Microsoft.Crm.UnifiedServiceDesk.Diagnostics Information 8 07/08/2021 11:56:40 AM Stopping Diagnostic tool
Microsoft.Crm.UnifiedServiceDesk.Diagnostics Error 2 07/08/2021 11:56:40 AM consolidateDiagnosticsFolder: maxFolderSize 5242880000 diagFolderSize 754210502 num dirs 659 num files 0
Microsoft.Crm.UnifiedServiceDesk.Diagnostics Information 8 07/08/2021 11:56:41 AM Stopped Diagnostic tool
Microsoft.Crm.UnifiedServiceDesk.ProcessMonitor Information 8 07/08/2021 11:56:41 AM Monitoring Process terminated with exit code 0 .
Microsoft.Crm.UnifiedServiceDesk.ProcessMonitor Information 8 07/08/2021 11:56:41 AM Monitoring Process terminated with exit code 1 .
Microsoft.Crm.UnifiedServiceDesk.ProcessMonitor Error 2 07/08/2021 11:56:41 AM Exception 0x33BC0116:Unknown exception occurred in the namedpipeserver object.
Microsoft.Crm.UnifiedServiceDesk.ProcessMonitor Error 2 07/08/2021 11:56:41 AM Message: Exception 0x33BC0110:
Source : mscorlib
Method : ThrowForNonSuccess
Time : 11:56:41 AM
Date : 07/08/2021
Error : A task was canceled.
Stack Trace : at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Windows.Threading.DispatcherOperation.Wait(TimeSpan timeout)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherOperation operation, CancellationToken cancellationToken, TimeSpan timeout)
at System.Windows.Threading.Dispatcher.Invoke[TResult](Func`1 callback, DispatcherPriority priority, CancellationToken cancellationToken, TimeSpan timeout)
at Microsoft.Crm.UnifiedServiceDesk.Dynamics.Utilities.SafeDispatcher.SafeInvokeOnStaThread(Delegate callback, DispatcherPriority dispatcherPriority, TimeSpan timeout, CancellationToken cancellationToken, Object[] args, Boolean safeMode)
at Microsoft.Crm.UnifiedServiceDesk.Dynamics.Utilities.SafeDispatcher.SafeInvokeInternal(Delegate callback, DispatcherPriority dispatcherPriority, TimeSpan timeSpan, CancellationToken cancellationToken, Object[] args, Boolean runOnMainUiThread, Boolean safeMode)
at Microsoft.Crm.UnifiedServiceDesk.Dynamics.Utilities.SafeDispatcher.Invoke(Action callback, Boolean runOnMainUiThread, Boolean safeMode)
at Microsoft.Crm.UnifiedServiceDesk.Dynamics.Utilities.GlobalHotkeys.Unregister(UInt16 hKeyId)
at Microsoft.Crm.UnifiedServiceDesk.Dynamics.Utilities.GlobalHotkeys.Dispose()
at Microsoft.Crm.UnifiedServiceDesk.Dynamics.Utilities.GlobalHotkeys.CurrentDomain_ProcessExit(Object sender, EventArgs e)