Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 4, 2026

MSAL 4.56.0's embedded WebBrowser authentication throws ArgumentException: ObjectForScripting's class must be visible to COM when connecting to Power Automate API via OAuth.

Changes

  • Configure AcquireTokenInteractive to use system browser instead of embedded WebView
authResult = await app
    .AcquireTokenInteractive(scopes)
    .WithTenantId(tenantId)
    .WithUseEmbeddedWebView(false)  // Added
    .ExecuteAsync();

This avoids MSAL's internal COM interop requirements while providing standard browser-based OAuth flow.

Original prompt

This section details on the original issue you should resolve

<issue_title>'Unhandled exception' error after clicking Connect to Power Automate API</issue_title>
<issue_description>FEH ver: 1.2025.10.2
XRMToolBox ver: 1.2025.10.73

Updated to the latest versions of XRMTB and FEH yesterday and am now getting the following error after clicking Connect to Power Automate API:

Image

I am connected to the environment using OAuth.

Full error text:

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ArgumentException: ObjectForScripting's class must be visible to COM.  Verify that the object is public, or consider adding the ComVisible attribute to your class.
   at System.Windows.Forms.WebBrowser.set_ObjectForScripting(Object value)
   at Microsoft.Identity.Client.Platforms.Features.WinFormsLegacyWebUi.InteractiveWebUI.OnAuthenticate(CancellationToken cancellationToken)
   at Microsoft.Identity.Client.Platforms.Features.WinFormsLegacyWebUi.WebUI.<>c__DisplayClass20_0.<AcquireAuthorizationAsync>b__0()
   at Microsoft.Identity.Client.Platforms.Features.WinFormsLegacyWebUi.WebUI.<AcquireAuthorizationAsync>d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Identity.Client.Internal.AuthCodeRequestComponent.<FetchAuthCodeAndPkceInternalAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Identity.Client.Internal.AuthCodeRequestComponent.<FetchAuthCodeAndPkceVerifierAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Identity.Client.Internal.Requests.InteractiveRequest.<GetTokenResponseAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Identity.Client.Internal.Requests.InteractiveRequest.<ExecuteAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Identity.Client.Internal.Requests.RequestBase.<RunAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Identity.Client.ApiConfig.Executors.PublicClientExecutor.<ExecuteAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Fic.XTB.FlowExecutionHistory.FlowExecutionHistory.<tsbConnectPowerAutomateApi_Click>d__49.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.9310.0 built by: NET481REL1LAST_C
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
----------------------------------------
XrmToolBox
    Assembly Version: 1.2025.10.73
    Win32 Version: 1.2025.10.73
    CodeBase: file:///C:/ProgramData/XRMToolbox/XrmToolBox.exe
----------------------------------------
XrmToolBox.Extensibility
    Assembly Version: 1.2025.7.71
    Win32 Version: 1.2025.7.71
    CodeBase: file:///C:/ProgramData/XRMToolbox/XrmToolBox.Extensibility.DLL
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.9251.0 built by: NET481REL1LAST_C
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 ...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes DynamicsNinja/FlowExecutionHistory#46

<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for you](https://github.com/DynamicsNinja/FlowExecutionHistory/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits February 4, 2026 08:14
Co-authored-by: DynamicsNinja <31212465+DynamicsNinja@users.noreply.github.com>
Co-authored-by: DynamicsNinja <31212465+DynamicsNinja@users.noreply.github.com>
Co-authored-by: DynamicsNinja <31212465+DynamicsNinja@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix unhandled exception error on Connect to Power Automate API Fix MSAL COM interop exception by forcing system browser authentication Feb 4, 2026
Copilot AI requested a review from DynamicsNinja February 4, 2026 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants