No one has responded to this discussion for at least a year, so this information may be out of date. If you're looking for information about this topic, please search for a more recent discussion or post a new question.

Exception of type 'Microsoft.Online.Administration.Automation.MicrosoftOnlineException' was thrown.

This question is answered This question is answered

I'm using code on to connect to Office 365 via c# web application


I'm getting this exception on the Pipeline.Invoke method on the Connect-MsolService cmdlet:

Exception of type 'Microsoft.Online.Administration.Automation.MicrosoftOnlineException' was thrown.

Already done so far:

  • Installed/enabled the required software (NET Framework 3.5, Microsoft Online Services Sign-In Assistant (64 bit), Microsoft Online Services Module for Windows PowerShell (64 bit))
  • set-executionpolicy remotesigned
  • Using primary admin account to connect
  • Using a Windows 2008 R2 64 bit machine.
  • Targeting 64 bit processor in VS, and .NET framework 4.5
  • IIS apppool for this web application is set to use .NET framework 4.0

I can successfully execute connect-msolservice and run cmdlets on the Microsoft Online Services Module for Windows PowerShell on the same machine, using same account.


What else can I try?


Verified Answer
  • Hi greatbear302,

    Have you deployed SSO with Office 365? If so, I suggest you create a non-federated admin user with domain to test it. Here's a KB article for more information about connecting to MSOL service under SSO environment

    I have searched another similar issue with a ASP.NET solution, which has been resolved by changing the Load User Profile to true in the app pool in IIS. You may also try looking for similar settings in your solution.

    Meanwhile, I would like to say that there are limited resources for programming issues in this forum, and a lot of great information can be seen in MSDN and TechNet. I recommend you ask this question in MSDN for a better response.

    MSDN forum

    Reken Liu 

    1 out of 1 people found this post helpful.

All Replies