web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to debug a system class that was called while running a power shell script!!

(0) ShareShare
ReportReport
Posted on by 446

Hi,

We are upgrading from AX 2012 to Dynamics 365 F&O, We are using a data upgrade deploy-able package that consists of several steps with several power shell scripts.

One of these steps is starting and stopping the batch service then failed.

We tried to run this script manually through power shell and we got the reason of failure was due to Dynamics 365 F&O method. (Class\ ReleaseUpdateDB72_Project\ updateProjCostTransWorkerToResource)

I reviewed this method and it seems to be OK but i would like to be sure by debugging this method while running the power shell script.

So, I need your support to know:

How to debug a method that was run by a power shell script? What is the process that i have to attach??(If Batch Service is stopped)

Thanks

I have the same question (0)
  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    Just knowing that the code is written in Powershell isn't sufficient - we need to know what the code does (i.e. which process it starts). If it's not clear from the error message, look into the script file. Share it with us if needed.

    You can also debug the script if you don't know where it fails.

  • Peter Samir Profile Picture
    446 on at

    Hi Martin,

    I checked the script file and it fails after running the following lines:

    #wait till postsync script finished

    $upgradeParameter = " --setupmode runstaticxppmethod --classname UpgradeServiceHelper --methodname WaitForDataUpgradeToComplete"

    Write-Output "monitoring postsync"

    Start-Process $command $($commandParameter+$upgradeParameter) -PassThru -Wait -RedirectStandardError "$LogDir\dbUpgradePostSyncMonitor.error.log"

    $dbupgradeError = Get-Content "$LogDir\dbUpgradePostSyncMonitor.error.log"

    The log file for the failed step is as follow:

    08/17/2020 14:39:35: Infolog diagnostic message: 'Script Error(s) found. Please refer to the ReleaseUpdateScriptsErrorLog table for details' on category 'Error'.
    08/17/2020 14:39:37: Application configuration sync failed. Microsoft.Dynamics.AX.Framework.Database.TableSyncException: Custom action threw exception(s), please investigate before synchronizing again: 'ErrorException:
    at Dynamics.AX.Application.UpgradeServiceHelper.`waitForUpgrade(UpgradeServiceContract _upgradeService, ReleaseUpdateLogManager _logManager, Int32 _maxIterations) in xppSource://Source/ApplicationFoundation\AxClass_UpgradeServiceHelper.xpp:line 174
    at Dynamics.AX.Application.UpgradeServiceHelper.waitForUpgrade(UpgradeServiceContract _upgradeService, ReleaseUpdateLogManager _logManager, Int32 _maxIterations)
    at Dynamics.AX.Application.UpgradeServiceHelper.`WaitForDataUpgradeToComplete() in xppSource://Source/ApplicationFoundation\AxClass_UpgradeServiceHelper.xpp:line 140
    at Dynamics.AX.Application.UpgradeServiceHelper.WaitForDataUpgradeToComplete()
    at UpgradeServiceHelper::WaitForDataUpgradeToComplete(Object[] , Boolean& )
    at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters)
    at Microsoft.Dynamics.AX.Deployment.Setup.AppOperations.RunStaticXppMethod(String className, String methodName, String methodInput, String partitionName)
    at Microsoft.Dynamics.AX.Framework.Database.Tools.LegacyCodepath.<>c__DisplayClass29_0.<NOTE_LeavingSynchronizer_CallStackAboveThisLineIsCustomCode>b__0()
    at Microsoft.Dynamics.AX.Framework.Database.Tools.LegacyCodepath.ExecuteWithinAOS(SyncOptions syncOptions, String sqlConnectionString, IMetadataProvider metadataProvider, Func`1 func, Action`1 errorHandler)' ---> Microsoft.Dynamics.Ax.Xpp.ErrorException
    at Dynamics.AX.Application.UpgradeServiceHelper.`waitForUpgrade(UpgradeServiceContract _upgradeService, ReleaseUpdateLogManager _logManager, Int32 _maxIterations) in xppSource://Source/ApplicationFoundation\AxClass_UpgradeServiceHelper.xpp:line 174
    at Dynamics.AX.Application.UpgradeServiceHelper.waitForUpgrade(UpgradeServiceContract _upgradeService, ReleaseUpdateLogManager _logManager, Int32 _maxIterations)
    at Dynamics.AX.Application.UpgradeServiceHelper.`WaitForDataUpgradeToComplete() in xppSource://Source/ApplicationFoundation\AxClass_UpgradeServiceHelper.xpp:line 140
    at Dynamics.AX.Application.UpgradeServiceHelper.WaitForDataUpgradeToComplete()
    at UpgradeServiceHelper::WaitForDataUpgradeToComplete(Object[] , Boolean& )
    at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters)
    at Microsoft.Dynamics.AX.Deployment.Setup.AppOperations.RunStaticXppMethod(String className, String methodName, String methodInput, String partitionName)
    at Microsoft.Dynamics.AX.Framework.Database.Tools.LegacyCodepath.<>c__DisplayClass29_0.<NOTE_LeavingSynchronizer_CallStackAboveThisLineIsCustomCode>b__0()
    at Microsoft.Dynamics.AX.Framework.Database.Tools.LegacyCodepath.ExecuteWithinAOS(SyncOptions syncOptions, String sqlConnectionString, IMetadataProvider metadataProvider, Func`1 func, Action`1 errorHandler)
    --- End of inner exception stack trace ---
    at Microsoft.Dynamics.AX.Framework.Database.Tools.LegacyCodepath.<>c.<NOTE_LeavingSynchronizer_CallStackAboveThisLineIsCustomCode>b__29_1(Tuple`2 result)
    at Microsoft.Dynamics.AX.Framework.Database.Tools.LegacyCodepath.ExecuteWithinAOS(SyncOptions syncOptions, String sqlConnectionString, IMetadataProvider metadataProvider, Func`1 func, Action`1 errorHandler)
    at Microsoft.Dynamics.AX.Framework.Database.Tools.LegacyCodepath.NOTE_LeavingSynchronizer_CallStackAboveThisLineIsCustomCode(SyncOptions syncOptions, String sqlConnectionString, IMetadataProvider metadataProvider, Action`1 a)
    at Microsoft.Dynamics.AX.Framework.Database.Tools.LegacyCodepath.RunCustomAction(SyncOptions syncOptions, String sqlConnectionString, IMetadataProvider metadataProvider, Action`1 a)
    at Microsoft.Dynamics.AX.Framework.Database.Tools.SyncEngine.PostTableSync()
    at Microsoft.Dynamics.AX.Framework.Database.Tools.SyncEngine.PartialSync()
    at Microsoft.Dynamics.AX.Framework.Database.Tools.SyncEngine.RunSync()
    at Microsoft.Dynamics.AX.Framework.Database.Tools.SyncEngine.Run(String metadataDirectory, String sqlConnectionString, SyncOptions options)
    08/17/2020 14:39:37: The operation failed.

  • Verified answer
    Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    What process will be started is defined by $command variable.

  • Peter Samir Profile Picture
    446 on at

    Thanks Martin,

    I checked $command variable and its value is (K:\AosService\WebRoot\bin\Microsoft.Dynamics.AX.Deployment.Setup.exe)

    8741.Untitled.png

  • Verified answer
    Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    This seems to answer what process you should debug. If it fails before you get a chance to attach the debugger, try this: Debug an app that isn't part of a Visual Studio solution.

  • Peter Samir Profile Picture
    446 on at

    Thanks Martin, much appreciated.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 611 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans