03.12.2016, 15:15 | #1 |
Участник
|
goshoom: Find assembly for a given type – in AX 7
Источник: http://dev.goshoom.net/en/2016/12/fi...-type-in-ax-7/
============== Five years ago, I wrote a blog post called Assembly containing a given type, demonstrating how to find the assembly where a given type is defined. I needed the same thing in AX 7, but instead of using the same code, I decided to utilize the fact that I can now easily write parts of my application in C#. I added a C# class library project to the assembly with my X++ project and created a class with this method: public static System.Reflection.Assembly findAssembly(string typeName){ var assemblies = AppDomain.CurrentDomain.GetAssemblies(); return assemblies.FirstOrDefault(a => a.GetType(typeName, false, true) != null);} I built the solution, went to my X++ project and added a project reference to the C# project. (Right-click References node, choose Add reference…, select the project on the Projects tab and confirm.) This allowed me to call my C# method from X++, which I did: var assembly = MyClassLibrary.MyClass::findAssembly('Dynamics.AX.Application.AsyncTaskResult');if (assembly != null){ info(assembly.FullName); info(assembly.Location);} I saved a few lines of code, but more importantly I showed you how easy it is to use C# projects together with X++ projects. It’s extremely powerful, because C# (and other .NET languages) give you quite a few options that you don’t have in X++ (although it’s not the case of this particular example). Источник: http://dev.goshoom.net/en/2016/12/fi...-type-in-ax-7/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|