Skip to main content

Notifications

Announcements

No record found.

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

Reference to a model

(0) ShareShare
ReportReport
Posted on by 32

Hello everyone,

I'm developing a solution for D365 FO, which consist of 2 projects X++ and C#. I have followed Microsoft Docs article https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/dev-tools/write-business-logic

where it says to include reference to a model and set the property Copy Local = False which I did. But when I move it to another environment this reference is missing. Do I need to include something in VSTS before shelving/checking in?

Thank you in advance,

Alex

  • Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: Reference to a model

    Hi Alex,

    Could you, please, also provide more information about another environment? Is it another D365 devbox or build VM or something else?

  • Sukrut Parab Profile Picture
    Sukrut Parab 71,671 Moderator on at
    RE: Reference to a model

    Once you add reference of your dll to project it gets copied over to bin folder of the model you are working in. You have to add that reference (dll reference xml)to your  source  control.

    When you generate build , at that time it gets packaged as a part of deployable package and you deliver that deployable package to managed environment i.e. UAT or production. Is that something are you looking for ?

  • Alex Nach Profile Picture
    Alex Nach 32 on at
    RE: Reference to a model

    Hi Sukrut. That makes no sense to me. This article from Microsoft docs shows how it can be done: docs.microsoft.com/.../write-business-logic What it doesn't show/speaks of is how it needs to be moved from one environment to another and this is where I'm straggling. If D365 development is possible with X++ why would C# would be different? Again, I'm new to this D365 development but I have 20+ experience with .NET programming so there has to be a better way. Thank you. Alex  

  • Alex Nach Profile Picture
    Alex Nach 32 on at
    RE: Reference to a model

    Yes, the paths wouldn't match. Again, the article from Microsoft docs tells to add "model reference" and set the property Copy Local = False.

    It makes no sense to copy model since dll constantly changes but then how do you move solution from one environment to another? There must be a way to do it. I just don't know how. Thank you.

  • Suggested answer
    Sukrut Parab Profile Picture
    Sukrut Parab 71,671 Moderator on at
    RE: Reference to a model

    -------------------------------------------------------------------------------------------------------------------------------

    I was referring to the d365 model though that my company is using to build any custom solutions. Do I need to add D365 model dll as well the same way I added C# dll? I'm referencing several tables from within C# project.

    I thought about copying it into the bin C# folder like I did with other Microsoft.Dynamics.AX.Framework references but isn't that bad ?

    -----------------------------------------------------------------------------------------------------------------------------

    Hi Alex ,

    If you are trying to  use D365 model dll same as you used external dll in your D365 code then that's  not the correct way to expose business logic with D365 for F or SC. There are different integration  approach to integrate external application with D365 . Take a look at below link to learn about those. 

    https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/data-entities/integration-overview

    Apart from these you can use power Automate , logic apps and difference azure app services to do integration  with D365.

  • Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: Reference to a model

    Hi Alex,

    It took some time to prepare my own example.

    I've made the next steps:

    1. Create new D365 model + project

    2. Create new C# project and add references like in article (i used K:\Packages and it's a shortcut to K:\AosService\PackagesLocalDirectory)

    3. Added reference in D365 to C# project

    4. Added dll produced by C# project from D365 model bin folder to source control

    5. C# project added to source control

    6. Opened another environment and got latest version, but in my case, all references in C# project are in place, because K:\Packages folder exists in this environment too. But if I open C# project in another environment where K:\Package doesn't exist it I will get broken reference and i need to re-add it with the correct source.

    I guess you are trying to test C# project instead of D365 model, but you will anyway deliver to sandbox\prod environment D365 model and C# dll included in bin folder from step 4.  Am I correct?

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,703 Super User 2024 Season 2 on at
    RE: Reference to a model

    Moved to the Dynamics 365 Finance forum.

  • Alex Nach Profile Picture
    Alex Nach 32 on at
    RE: Reference to a model

    yes. I added model to  C# as reference, as per article, but when I shelve my project and move to another environment, the model reference is broken.

    7635.Capture1.JPG

  • Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: Reference to a model

    Hi Alex,

    Now i understand. You have also reference to D365 model in C# project. So you have D365 model dll in C:\Package and reference it in C# project. But still you have reference to C# project in D365 model. When you build C# project it will produce dll and put to D365 model bin folder and you add it to source control.

    Then you deliver D365 model to QA environment and link to C# dll is missing? Or you are trying to deliver C# project to QA environment?

  • Alex Nach Profile Picture
    Alex Nach 32 on at
    RE: Reference to a model

    Not exactly Sergei. From the article I posted link to (this step in particular):

    7. In Solution Explorer, select the reference Dynamics.Ax.FleetManagement.dll reference and set the property Copy Local = False.

    I did the same in my solution. The only difference is I have different model, not FleetManagement. I need this reference to access D365 tables and do inserts from within C# project. When I move solution to QA environment this reference is missing (no path). In development, everything is on C: drive and on other environments drive could be very different. I hope this helps.

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,433 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans