ExchangeOnline module hangs

Tool: Visual Studio 2019 PS Pro Tools
Version: 2019. Compiled as exe, dotnet 4.72

My Project Compiles and runs fine… It loads the AD module, then the Aure AD module, but hangs loading the Exchange online module. Running the code direct on PS works fine.
Connect-ExchangeOnline -userprincipalname $msAccountName
The code gets as far as

then just sits there. Normally, I would see an authentication dialogue box.
Note, I need to use this method as we have MFA in play. Hvaen been trying to troubleshoot this for a couple of days, and I’m stumped!

Can you share the PS proj you are trying to compile like this? A couple things come to mind are the thread apartment state and x64 vs x86 but having a reference on the settings you are using would be helpful.

Hi Adam, happy to share with you directly, but wouldn’t want to put the code in the public arena (yet)
I can send you a onedrive link if that works?
Using PS x64

many thanks