Error “Cannot access a disposed object” when deploying AX 2009 Enterprise Portal on a SharePoint 2010 server

After following through suggestions on deploying Microsoft Dynamics AX 2009 Role Centers and Enterprise portal (RC+EP), we ran across another issue when deploying the RC+EP extensions. We get the following error in the DynamicsSetupLog.txt file:

Entering function ConfigureVirtualServerWithNewApplicationPool

Entering function GenerateNewApplicationPoolId
SharePoint_80_07d99c07c0184c8bbce6472ec69f1a87
Leaving function GenerateNewApplicationPoolId
Creating new application pool SharePoint_80_07d99c07c0184c8bbce6472ec69f1a87
An error occurred during setup of Role Centers and Enterprise Portal.
Reason: Cannot access a disposed object.
=== Rolling back setup of Role Centers and Enterprise Portal due to error ===

The above error occurs if:

(a) You are deploying to an existing web site created in SharePoint 2010 and
(b) The application pool user account associated with this web site is not the bcproxy user account

The Application pool associated with the EP web site nust run as the BCProxy user account setup in your AX environment.

To resolve this issue change the application pool account using SharePoint 2010 Administration. Do not directly change the account in the application pool using IIS Manager:

(1) Run SharePoint 2010 Central Administration

(2) Click on Security on the left-hand bar

(3) Under General Security click on Configure managed accounts

(4) Click on the link Register Managed Account and add the BCProxy user account that is setup for your AX environment.

(5) Now change the application pool user as follows. Click on Security on the left-hand bar and then under General Security click on Configure service accounts.

(6) From the Select one… drop-down box, select the Web Application Pool associated with your EP Web site and under Select an account for this component, select the BCProxy user account you just added above, and click OK.

(7) Read the message that is displayed and click OK.

(8) Wait for the changes to apply, and if successful, the Security form will be shown again.

(8) Run IIS Manager, and under application pools, verify that the new account is now displayed

(9) Open up an elevated cmd prompt an run IISRESET.EXE /noforce on all your servers in the farm.