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 :
Microsoft Dynamics AX (Archived)

Is it possible to run the c# code from the project without adding the dll to D365 project?

(0) ShareShare
ReportReport
Posted on by

I am working on the D365FO app and develop business logic in c# and call this business logic from DataEntity. The problem I am having is once you add a new function to c# library project and generate dll I need to stop the IIS and re-reference the dll in D365 project and start the IIS back. Sometimes new function is not recognized with D365 and try to many different things(restart visual studio, rebooting) in order for D365 project to recognize the new function added to the assembly project. It would be nice if I can run the c# library project so I can test all new functions then when all the functions are working fine I want to reference to the D365 project. Is it easy way to run this c# libary project by itself without adding the reference to D365 project?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Srini Ramidi Profile Picture
    2 on at

    Hello,

    YES, you can create C# library if you don't need any reference to D365 objects. I  did sort of same thing recently,created c# library to process the web service request and returns the response back to requester(data entity).  Also you can create a command line application and reference the C# lib to test the business logic.

    Best,

    Srini    

  • Community Member Profile Picture
    on at

    Do you also use Microsoft.Dynamics.AX.Framework.Linq? We use angular UI for frontend development and talking to server using Data Entity where I call business logic in c# assembly code. Every time I add a new method in c# and reference the dll in D365 project it takes 30 minutes to figure out why new method is not recognized in the D365 project because sometimes it's just restarting visual studio sometimes rebooting the computer or just restarting IIS. So It would be nice if I can add all methods I need and test in c# lib project. How would I set up so I can run and debug this c# lib project?

  • Srini Ramidi Profile Picture
    2 on at

    No i did not use any objects from D365. My code is loosely coupled with the implementation of web service call  and not depend anything on D365.

  • Community Member Profile Picture
    on at

    But I guess if I add unit test project and call those function in the library I might be able to debug easy.

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

    You're still talking about a DLL, which suggests you built the class library separately and added a reference to the file, not to the class library project.

    Try putting your C# class library project and your AX project to a single solution and adding a project reference in the AX project. It will make things easier; what you're describing sounds horrible. :-)

  • Community Member Profile Picture
    on at

    Thanks Martin.

  • Community Member Profile Picture
    on at

    I have tried to put the c# library in the D365 solution but the situation didn't change at all.

    Is it possible how I can pass list from c# to x++ causing this problem?

     

    c#

    namespace MyApp.Services
    {
      public class MyService{
        public List<Microsoft.Dynamics.Ax.Xpp.Common> GetMyList(Dynamics.AX.Application.MySearchObj searchObj)
        {
          var myObjQueryCollection = new QueryCollection<MyObj>(provider);
          var result = from items in myObjQuery.where( m => m.name == searchObj.filterText)
                       select item;
          var commonItemList = new List<Microsoft.Dynamics.Ax.Xpp.Common>();
    
          if (tempList != null) {
            foreach (MyObj item in result.ToList())
            {
              commonItemList.Add(item);
            }
          }
    
          return commonItemList;
        }
      }    
    }


    x++

    public class MyWebEntity extends common
    {      
        [SysODataActionAttribute("FilterList", false),SysODataCollectionAttribute("return", Types::Record, "MyWebEntity")]
        public static List FilterList()
        {
          List myLst = new List(Types::Record);
          MyApp.Services.MyService myService = new MyApp.Services.MyService();          
          Dynamics.AX.Application.MySearchObj mySearchObj = new Dynamics.AX.Application.MySearchObj();
          mySearchObj.filterText = "My stuff";
          System.Collections.IEnumerable list;
    
          myList = myService.GetMyList(mySearchObj);      
    
          return myLst;
        }
    }


  • Martin Dráb Profile Picture
    237,970 Most Valuable Professional on at

    It's because your problem is about a different reference - about the place where you refer to AX from your C# library (which you never mentioned). At least that's my understanding.

  • Community Member Profile Picture
    on at

    After days of researching I have found out about c# library and D365. When I create a function with table object(Dynamics.AX.Application.*) as parameters in C# library the D365 project doesn't recognize the function right away. Sometimes I have to reboot the machine so it does recognize and I can build the model.

    However when I create a function without parameters or with native object(int,string,etc...) the D365 application will recognize newly added function right away after restarting IIS and Visual Studio. Is this a bug or I am not supposed to use table objects as parameters in c# library?

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

    All right, thank you for confirming my theory. When we now know what reference is it about, let's look at what problem you have with it.

    Please realize that if you rebuild Application Suite, you change a dependency of your C# library. Therefore you may have to rebuild it and then your AX code using it. If you rebuild ApplicationSuite in the last step, you get back to the beginning...

    Note that you didn't tell us what you build at what time and in which package your code is, so I can't be more specific.

    In either case, if you don't have to refer to AX code from your C# library (or you'll get rid of it completely), you'll make your life easier. Building the logic above in X++ only would make a better sense than your current complicated solution.

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans