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, ...
Suggested Answer

D365fo DB sync issue

(0) ShareShare
ReportReport
Posted on by 349

Hi,

I am facing the below sync issue :

Severity Code Description Project File Line Suppression State
Error System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.Dynamics.Ax.Xpp.EventHandlerInitializationException: An exception was encountered while initializing event handler initializer 'InitMethod' on type 'Dynamics.AX.Application.EventHandler.EventHandlersInitializeClass, Dynamics.AX.XXX, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. ---> System.TypeLoadException: Could not load type 'Dynamics.AX.Application.NAVProjWorkBreakdownStructureV2_Eventhandler' from assembly 'Dynamics.AX.XXX, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. 0
Error at Microsoft.Dynamics.AX.Framework.Database.Tools.LegacyCodepath.RunPartialTableSync(SyncOptions options, String sqlConnectionString, IMetadataProvider metadataProvider) 0
Error --- End of inner exception stack trace --- 0
Error at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.InitializeMetadataEventHandler() 0
Error at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.<>c.<InitializeMetadataEventHandler>b__84_0(MethodInfo eventHandler) 0
Error at Dynamics.AX.Application.EventHandler.EventHandlersInitializeClass.InitMethod() 0
Error at Microsoft.Dynamics.AX.Framework.Database.Tools.SyncEngine.Run(String metadataDirectory, String sqlConnectionString, SyncOptions options) 0
Error at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) 0
Error at Microsoft.Dynamics.AX.Framework.Database.Tools.LegacyCodepath.RunPartialTableSync(SyncOptions options, String sqlConnectionString, IMetadataProvider metadataProvider) 0
Error at Microsoft.Dynamics.AX.AosConfig.Config.InitOnce(Boolean isOfflineMode) 0
Error Inner Exception: An exception was encountered while initializing event handler initializer 'InitMethod' on type 'Dynamics.AX.Application.EventHandler.EventHandlersInitializeClass, Dynamics.AX.XXX, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. 0
Error at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) 0
Error Database synchronization failed. You may have to do a full build of the package 'XXX' and all of its dependent packages. 0
Error at Microsoft.Dynamics.AX.AosConfig.Config.InitOnce(Boolean isOfflineMode) 0
Error at Microsoft.Dynamics.AX.Framework.Database.Tools.SyncEngine.PartialTableViewSync() 0
Error at Microsoft.Dynamics.AX.Framework.Database.Tools.SyncEngine.PartialTableViewSync() 0
Error at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) 0
Error at Microsoft.Dynamics.AX.Framework.Database.Tools.LegacyCodepath.ExecuteWithinAOS(SyncOptions syncOptions, String sqlConnectionString, IMetadataProvider metadataProvider, Func`1 func, Action`1 errorHandler) 0
Error at Microsoft.Dynamics.AX.AosConfig.Config.InitInternal() 0
Error at Microsoft.Dynamics.AX.Framework.Database.Tools.LegacyCodepath.StartAosCode(SyncOptions syncOptions, String sqlConnectionString, IMetadataProvider metadataProvider) 0
Error at Microsoft.Dynamics.AX.AOS.Startup() 0
Error at Microsoft.Dynamics.AX.Framework.Database.Tools.LegacyCodepath.ExecuteWithinAOS(SyncOptions syncOptions, String sqlConnectionString, IMetadataProvider metadataProvider, Func`1 func, Action`1 errorHandler) 0
Error at Microsoft.Dynamics.AX.AOS.StartupInternal(String[] Arguments) 0
Error at Microsoft.Dynamics.AX.AosConfig.Config.InitInternal() 0
Error Inner Exception: System.TypeLoadException: Could not load type 'Dynamics.AX.Application.NAVProjWorkBreakdownStructureV2_Eventhandler' from assembly 'Dynamics.AX.XXX, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. 0
Error at Microsoft.Dynamics.AX.AosConfig.?A0x6d51cb5c.GetAosConfig() 0
Error --- End of inner exception stack trace --- 0
Error at Microsoft.Dynamics.AX.AosConfig.?A0x6d51cb5c.GetAosConfig() 0
Error at Microsoft.Dynamics.AX.AOS.StartupInternal(String[] Arguments) 0
Error at Microsoft.Dynamics.AX.Framework.Database.Tools.SyncEngine.RunSync() 0
Error at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.InitializeMetadataEventHandler() 0
Error at Microsoft.Dynamics.AX.Framework.Database.Tools.LegacyCodepath.StartAosCode(SyncOptions syncOptions, String sqlConnectionString, IMetadataProvider metadataProvider) 0
Error at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) 0
Error at Microsoft.Dynamics.AX.Framework.Database.Tools.SyncEngine.PartialSync() 0
Error at Microsoft.Dynamics.AX.Framework.Database.Tools.SyncEngine.RunSync() 0
Error Database synchronization failed. You may have to do a full build of the package 'XXX' and all of its dependent packages. 0
Error Inner Exception: System.TypeLoadException: Could not load type 'Dynamics.AX.Application.NAVProjWorkBreakdownStructureV2_Eventhandler' from assembly 'Dynamics.AX.XXX, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. 0
Error at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.<>c.<InitializeMetadataEventHandler>b__84_0(MethodInfo eventHandler) 0
Error Inner Exception: An exception was encountered while initializing event handler initializer 'InitMethod' on type 'Dynamics.AX.Application.EventHandler.EventHandlersInitializeClass, Dynamics.AX.XXX, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. 0
Error at Dynamics.AX.Application.EventHandler.EventHandlersInitializeClass.InitMethod() 0
Error at Microsoft.Dynamics.AX.Framework.Database.Tools.SyncEngine.Run(String metadataDirectory, String sqlConnectionString, SyncOptions options) 0
Error System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.Dynamics.Ax.Xpp.EventHandlerInitializationException: An exception was encountered while initializing event handler initializer 'InitMethod' on type 'Dynamics.AX.Application.EventHandler.EventHandlersInitializeClass, Dynamics.AX.XXX, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. ---> System.TypeLoadException: Could not load type 'Dynamics.AX.Application.NAVProjWorkBreakdownStructureV2_Eventhandler' from assembly 'Dynamics.AX.XXX, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. 0
Error at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) 0
Error at Microsoft.Dynamics.AX.AOS.Startup() 0
Error at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) 0
Error at Microsoft.Dynamics.AX.Framework.Database.Tools.SyncEngine.PartialSync() 0
Error syncengine.exe exited with code -1. 1
Error syncengine.exe exited with code -1. 1

Please help resolve this.

Thanks in advance.

I have the same question (0)
  • GirishS Profile Picture
    27,827 Moderator on at

    Hi Priya,

    Have you created any class like "NAVProjWorkBreakdownStructureV2"?

    Thanks,

    Girish S.

  • Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    Hi PriyaDutta,

    Can you show me the event handler code which is shown in the error log?

  • PriyaDutta Profile Picture
    349 on at

    Hi Girish,

    Yes I have created an event handler class "NAVProjWorkBreakdownStructureV2_Eventhandler"

  • PriyaDutta Profile Picture
    349 on at

    Hi Bharani,

    Please find the below code.

    class NAVProjWorkBreakdownStructureV2_Eventhandler
    {
        /// 
        ///
        /// 
        /// 
        /// 
        [FormDataFieldEventHandler(formDataFieldStr(ProjWorkBreakdownStructureV2, ProjPlanVersion, NAVUnitSalesPrice), FormDataFieldEventType::Modified)]
        public static void NAVUnitSalesPrice_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
        {
            FormDataSource projPlanVersion_ds = sender.datasource();
            FormRun form = projPlanVersion_ds.formRun();
            ProjPlanVersion projPlanVersion = projPlanVersion_ds.cursor();
            
            
            projPlanVersion.NAVTotalSalesPrice = projPlanVersion.NAVUnitSalesPrice * projPlanVersion.TaskEffort;
    
            ProjPlanVersion::NAVUpdateProjPlanVersion(projPlanVersion);
            //projPlanVersion_ds.reread();
            projPlanVersion_ds.research();
    
           form.updateDataSourcesKeepCursor();
           
            
        }
    
        [FormDataFieldEventHandler(formDataFieldStr(ProjWorkBreakdownStructureV2, ProjPlanVersion, TaskEffort), FormDataFieldEventType::Modified)]
        public static void TaskEffort_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
        {
            FormDataSource projPlanVersion_ds = sender.datasource();
            FormRun form = projPlanVersion_ds.formRun();
            ProjPlanVersion projPlanVersion = projPlanVersion_ds.cursor();
            
            projPlanVersion.NAVTotalSalesPrice = projPlanVersion.NAVUnitSalesPrice * projPlanVersion.TaskEffort;
            ProjPlanVersion::NAVUpdateProjPlanVersion(projPlanVersion);
           // projPlanVersion_ds.reread();
           projPlanVersion_ds.research();
        }
    
    }

  • GirishS Profile Picture
    27,827 Moderator on at

    Try build the model that belongs to the event handler class without synchronization.

    Thanks,

    Girish S.

  • PriyaDutta Profile Picture
    349 on at

    Hi Girish,

    I have changed the class name .

    Done full build of the model. There is no error.

    But sync is giving error.

  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    Similar issue is explained in the below thread. Try the suggestion given in the below thread.

    https://community.dynamics.com/ax/f/microsoft-dynamics-ax-forum/258699/error-deploying-package-in-test-environment-during-db-synchronization/725853

    Thanks,

    Girish S.

  • Deepak Agarwal Profile Picture
    8,602 on at

    Hi Priya,

    Did you make any change in any existing table properties. Also comment your code from event handler class and try again.

  • PriyaDutta Profile Picture
    349 on at

    Hi Girish,

    Looks like similar issue.

    I found that for Dev and Test environment have different versions.

    pastedimage1669715210786v1.png

    pastedimage1669715228421v2.png

    Is it because of this ? Should I update the version in test environment first ?

  • Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    Hi Priya,

    Pease update the environment. Even I have faced the same issue. Because all the code should be in sync and some features will be deprecated in new update. So it is always good idea to keep all the environments in one version.

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 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans