How to Use a .NET Project Within a D365FO Solution
step1 : create a x++ project
step2 : Select Class Library (.NET Framework)
step3: Enter a Project Name and Location, then select .NET Framework 4.7.2 – the reason for this is that if we want to reference any Microsoft DLLs we need to be sure our solution matches the project type and version that the DLLs are built against (which in the case of Microsoft DLLs is .NET Framework 4.7.2)
step4 : Next we need to create a reference between our X++ project and our .NET project, right click on the References and ‘Add Reference’
step5 : Next select your .NET project from the Projects tab
step6 : Now you will see your .NET project is referenced by your X++ project
So Now I Can Reference Microsoft DLLs from the .NET Class?
3) Navigate to the PackagesLocalDirectory folder (on my development onebox this is located at K:\AosService\PackagesLocalDirectory) then look for the bin folder. This folder contains the built DLLs that are included with your D365FO instance.
And How Do I Call This .NET Method From X++?
Since we are referencing our .NET project in our X++ solution we can add a using statement to our X++ class to the FpTestNet project and then reference the .NET class and method within our X++ code. Note here that you have to follow the syntax of: <.NetClass>::<.NetMethod>. When we execute the code you can see the correct menu item displays are returned in a JSON format that we can then utilize within our X++ project or return to a service operation endpoint to an external solution.
Comments
Post a Comment