Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

Error in extension class causes compiler to crash

Posted on by 74
Hi. Here is a summary of what I am trying to achieve. 
 
  1. I want to display a real field Sales Price in the InventOnHandItem form. 
  2. The Sales Price = Cost price * 1.25
  3. The Cost Price field is displayed by a system default method called AverageCostPriceUnit from the Data source on the form - InventSum
  4. The actual table InventSum does not have this method. It only exists on the Data source to the form InventOnhandItem. 
  5. I am trying to write a class with a method that will extend the existing method so that I can use AverageCostPriceUnit * 1.25 and display the result in my real field Sales Price.
  6. The code I wrote is as follows: 
7. I bind it to the control field Sales Price with data method field as Invent_Extension::calculatedUnitSalesPrice
 
8. When building this class, the compilation fails and it says X++ compiler exited unexpectedly with failure code -1. 
 
9. This does not happen if I delete/remove the class and the compiler completes successfully in that case.
 
I Appreciate your support/advice to know where I am going wrong and what can be done to fix the issue. 
 
 
 
 
 
The entire build log is as follows: 
 
Build started 08/12/2024 18:24:41.
Build step: Metadata validation started. Time: 08/12/2024 18:24:41
Build step: Metadata validation completed (581 ms). Time: 08/12/2024 18:24:41
Build step: X++ compilation started. Time: 08/12/2024 18:24:42
  : Compilation failed.
C:\AOSService\PackagesLocalDirectory\ApplicationCommon\ApplicationCommon\AxReference\Microsoft.Commerce.Flighting.Common.xml(0,0):  AssemblyFileNotFound: Assembly 'Microsoft.Xbox.Experimentation.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d91bba2b903dc20f' failed to load because it was not found.
C:\AOSService\PackagesLocalDirectory\ApplicationSuite\Foundation\AxReference\Microsoft.Dynamics___vices.PricingEngine.xml(0,0):  AssemblyFileNotFound: Assembly 'Microsoft.Dynamics.Commerce.Runtime.Entities.AttributeBasedPricing, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' failed to load because it was not found.
C:\AOSService\PackagesLocalDirectory\ApplicationSuite\Foundation\AxReference\Azure.Core.xml(0,0):  AssemblyFileNotFound: Assembly 'System.Memory.Data, Version=1.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' failed to load because it was not found.
C:\AOSService\PackagesLocalDirectory\FleetManagement\FleetManagement\AxClass\Invent_Extension.xml(0,0):  UnhandledException: Abnormal termination with unhandled exception. Exception key: 79899e16-0eef-4884-b4b9-24e0227aadee. System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at Microsoft.Dynamics.AX.Framework.Xlnt.XppParser.Pass2.TypeResolver.ValidateFormNestedElementsExtensionOf(SemanticFormType semanticFormType, IEnumerable`1 extesionOfParamters)
   at Microsoft.Dynamics.AX.Framework.Xlnt.XppParser.Pass2.TypeResolver.CheckForExtensionClassConstraints(SymbolTable payload, ClassOrInterface classOrInterface)
   at Microsoft.Dynamics.AX.Framework.Xlnt.XppParser.Pass2.TypeResolver.VisitClassOrInterface(SymbolTable payload, ClassOrInterface classOrInterface)
   at Microsoft.Dynamics.AX.Metadata.XppCompiler.AstVisitor`2.VisitModelElement(TPayload payload, ModelElement modelElement)
   at Microsoft.Dynamics.AX.Framework.Xlnt.XppParser.Pass2.TypeResolver.VisitModelElement(SymbolTable payload, ModelElement modelElement)
   at Microsoft.Dynamics.AX.Metadata.XppCompiler.AstVisitor`2.VisitCompilationUnit(TPayload payload, CompilationUnit compilationUnit)
   at Microsoft.Dynamics.AX.Metadata.XppCompiler.AstVisitorWithDiagnostics`2.VisitCompilationUnit(TPayload payload, CompilationUnit compilationUnit)
   at Microsoft.Dynamics.AX.Framework.Xlnt.XppParser.Pass2.TypeResolverPipelineEntry.Execute(CompilationUnit compilationUnit, TypeResolver resolver)
   at Microsoft.Dynamics.AX.Framework.Xlnt.XppParser.Pass2.Pipeline.ExecutePipeline(CompilationUnit compilationUnit, IDiagnosticSink diagnostics, IXppcMetadataProvider metadataProvider, Stack`1 context)
   at Microsoft.Dynamics.AX.Framework.Xlnt.XppParser.Pass2.MultipassAdministrator.RunPipeline(CompilationUnit compilationUnit, Pipeline pipeline)
   at Microsoft.Dynamics.AX.Framework.Xlnt.ILGenerator.ClassTypeGenerator.<>c__DisplayClass6_0.<RunPipeline>b__0(String name)
   at Microsoft.Dynamics.AX.Metadata.XppCompiler.ParallelCrashDumpUtil.<>c__DisplayClass1_0`1.<ForEach>b__2(T t)
   at System.Threading.Tasks.Parallel.<>c__DisplayClass42_0`2.<PartitionerForEachWorker>b__1()
   at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
   at System.Threading.Tasks.Task.<>c__DisplayClass176_0.<ExecuteSelfReplicating>b__0(Object ).
 X++ compiler exited unexpectedly with failure code -1.
Build step: X++ compilation completed (1702 ms). Time: 08/12/2024 18:24:43
Build step: Best practice check started. Time: 08/12/2024 18:24:43
Build step: Best practice check completed (481 ms). Time: 08/12/2024 18:24:44
Build completed (2862 ms). Time: 08/12/2024 18:24:44
 
 
  • VJ VM Profile Picture
    VJ VM 74 on at
    Error in extension class causes compiler to crash
    Still stumped over these errors, anyone? 
     
    C:\AOSService\PackagesLocalDirectory\ApplicationCommon\ApplicationCommon\AxReference\Microsoft.Commerce.Flighting.Common.xml(0,0):  AssemblyFileNotFound: Assembly 'Microsoft.Xbox.Experimentation.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d91bba2b903dc20f' failed to load because it was not found.

    C:\AOSService\PackagesLocalDirectory\ApplicationSuite\Foundation\AxReference\Microsoft.Dynamics___vices.PricingEngine.xml(0,0):  AssemblyFileNotFound: Assembly 'Microsoft.Dynamics.Commerce.Runtime.Entities.AttributeBasedPricing, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' failed to load because it was not found.

    C:\AOSService\PackagesLocalDirectory\ApplicationSuite\Foundation\AxReference\Azure.Core.xml(0,0):  AssemblyFileNotFound: Assembly 'System.Memory.Data, Version=1.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' failed to load because it was not found.
  • VJ VM Profile Picture
    VJ VM 74 on at
    Error in extension class causes compiler to crash
    Thanks, Martin. I just thought it would be simpler to keep the whole related query in one place which would be easier to understand for someone coming across the same problem. Anyhow, I will create a new thread for the issue. I have one last query about the compiler which I had asked earlier. I'll repeat that as follows.
     
    What are these errors and why do they appear? Also, is there a fix or I can safely ignore them? Thanks again!
     
    C:\AOSService\PackagesLocalDirectory\ApplicationCommon\ApplicationCommon\AxReference\Microsoft.Commerce.Flighting.Common.xml(0,0):  AssemblyFileNotFound: Assembly 'Microsoft.Xbox.Experimentation.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d91bba2b903dc20f' failed to load because it was not found.

    C:\AOSService\PackagesLocalDirectory\ApplicationSuite\Foundation\AxReference\Microsoft.Dynamics___vices.PricingEngine.xml(0,0):  AssemblyFileNotFound: Assembly 'Microsoft.Dynamics.Commerce.Runtime.Entities.AttributeBasedPricing, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' failed to load because it was not found.

    C:\AOSService\PackagesLocalDirectory\ApplicationSuite\Foundation\AxReference\Azure.Core.xml(0,0):  AssemblyFileNotFound: Assembly 'System.Memory.Data, Version=1.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' failed to load because it was not found.
     
     
  • Martin Dráb Profile Picture
    Martin Dráb 230,198 Most Valuable Professional on at
    Error in extension class causes compiler to crash
    We already were at this point of the discussion. The problem with the compiler crash is resolved, therefore this thread can be closed. Now you have another problem, when the compiler pointed out to a bug in your code, but that doesn't belong to this thread (it's not about "Error in extension class causes compiler to crash"). Therefore please create a new thread, give it an appropriate title and explain your problem there.
     
    You also missed that I already mentioned a logical bug in your code; let me repeat the remark:
    By the way, inventSum variable holds a record of InventSum table; the data source is in InventSum_ds (element.InventSum_ds) variable instead.
  • VJ VM Profile Picture
    VJ VM 74 on at
    Error in extension class causes compiler to crash
    Dear Martin, Thanks for getting back to me. 
     
    I restarted VS and the Abnormal termination error was still there. When I commented the function, the error disappeared and the following errors were returned. 
     
    C:\AOSService\PackagesLocalDirectory\ApplicationCommon\ApplicationCommon\AxReference\Microsoft.Commerce.Flighting.Common.xml(0,0):  AssemblyFileNotFound: Assembly 'Microsoft.Xbox.Experimentation.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d91bba2b903dc20f' failed to load because it was not found.
    C:\AOSService\PackagesLocalDirectory\ApplicationSuite\Foundation\AxReference\Microsoft.Dynamics___vices.PricingEngine.xml(0,0):  AssemblyFileNotFound: Assembly 'Microsoft.Dynamics.Commerce.Runtime.Entities.AttributeBasedPricing, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' failed to load because it was not found.
    C:\AOSService\PackagesLocalDirectory\ApplicationSuite\Foundation\AxReference\Azure.Core.xml(0,0):  AssemblyFileNotFound: Assembly 'System.Memory.Data, Version=1.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' failed to load because it was not found.
     
    After this, I removed the comment, clean & rebuild again, the above errors were there but the Abnormal termination error did not return. Compiler succeeded. This was some weird bug. 
     
    In addition to the above errors, I now have the below: 
     
    ClassDoesNotContainMethod: DataSource 'InventSum' does not contain a definition for method 'averageCostPriceUnit' and no extension method 'averageCostPriceUnit' accepting a first argument of type 'InventSum' is found on any extension class.
     
    Build step: X++ compilation completed (2298 ms). Time: 08/21/2024 09:18:04
     
    The standard method averageCostPriceUnit shows under the data source for the form, however, there's some reason this is not being accessed here. I cannot open the method to see its code either, while the standard "Cost Price" form control uses this as a data method and returns the average cost price. What am I doing wrong? I am simply trying to use this cost price value to multiply it with 1.25.
     
    Furthermore, what are the above errors that I am seeing? 
     
    Thanks Again!
     
  • Martin Dráb Profile Picture
    Martin Dráb 230,198 Most Valuable Professional on at
    Error in extension class causes compiler to crash
    Okay, so you're saying that you're still unable to compile your code, because the compiler crashes with the following error on Invent_Extension class:
     
    Abnormal termination with unhandled exception. Exception key:
    79899e16-0eef-4884-b4b9-24e0227aadee.
    System.ArgumentOutOfRangeException: Index was out of range. Must be
    non-negative and less than the size of the collection.

    Parameter name: index
     
    Please confirm that it's exactly the same error.
     
    Now, please comment out the whole calculatedUnitSalesPrice() and try it again. Does the compiler succeeds? Even if you restart Visual Studio. If it doesn't, it'll be clear that your problem isn't related to your code in the method.
     
    If it works, uncomment the method but let the body just return zero, instead of calling any of your code. Does it compile now?
  • VJ VM Profile Picture
    VJ VM 74 on at
    Error in extension class causes compiler to crash
    Dear Martin, Thanks for your response. I think there might have been a misunderstanding. I didn't say that the "compiler is no longer crashing with 'Index was out of range'" or that "it worked." I only mentioned the new error that appeared right after I fixed the first bug you found, even before running the build again. It was only after your last message, where you asked me to mark the answer, that I rebuilt it and discovered the original errors were also still present.
     
    I also realize now that the title of my post might have been misleading, as I needed help with the extension class & method itself, and the compiler crashing was just part of the issue. I appreciate your patience with me, as I am new to the scene and to community rules on creating/closing topics to the point. My intentions were not to mislead/confuse anyone or to waste anyone's time. Thanks!
     
  • Martin Dráb Profile Picture
    Martin Dráb 230,198 Most Valuable Professional on at
    Error in extension class causes compiler to crash
    Something what you said must be wrong. The previous information you gave us was that compiler is not crashing with "Index was out of range" anymore; you said it worked and pointed out to a bug in your code ("Table 'InventSum' does not contain a definition for method...").
     
    But now you're claiming the error is still the same as on the beginning.
     
    It can't be all true at the same time.
  • VJ VM Profile Picture
    VJ VM 74 on at
    Error in extension class causes compiler to crash
    Dear Waed Ayyad, 
     
    Thanks for your reply. As I mentioned in my original post, InventSum is the data source on the form InventOnHandItem. The method AverageCostPriceUnit exists only in the InventSum data source on the form and not on the actual InventSum Table. Yes, AverageCostPriceUnit is a standard method on the Data source and I cannot see its code. 
     
    Dear Martin, 
     
    I believe I tried to be as descriptive & provide as many details as I could in my post. I am still facing the same compile errors as the original post, despite correcting the bug. Is the compile error being caused by the class or could there be something else that's going wrong?
     
    Thanks!
  • Martin Dráb Profile Picture
    Martin Dráb 230,198 Most Valuable Professional on at
    Error in extension class causes compiler to crash
    It's good to hear that we've resolved the problem that this thread was about ("Error in extension class causes compiler to crash"). Please don't forget to verify the answer.
     
    Feel free to create new threads for other questions; give them descriptive title and give us enough details about your problem.

    By the way, inventSum variable holds a record of InventSum table; the data source is in InventSum_ds (element.InventSum_ds) variable instead.
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 6,332 Super User 2024 Season 2 on at
    Error in extension class causes compiler to crash
    Hi,
     
    The syntax to create an extension of form DataSource should be:
    [ExtensionOf(formDataSourceStr(YourForm, YourDataSourceName))]
    Where you define inventSum? Is it data source on the same form? What do you mean by you can't open the code? Is it a standard method?

    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
     

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans