I was experiencing an error in a standard Dynamics 365 F&O class that source code has not available. I needed to understand class internal behavior by analyzing source code.

To decompile a class using ILSpy or Jet Brains dotPeek is required to know the assembly file path in the file system.

For some objects is not straightforward to get matching assembly file.

Instead of browsing and expanding assemblies one by one, there is an easy way to get assembly for a class/table, etc.

public static void Main(Args _args)
{
    System.Object               obj;
    System.Type                 type;
    System.Reflection.Assembly  assembly;
    
    var cache = new SysGlobalObjectCache();
    type = cache.GetType();
    assembly = type.Assembly;
    
    info(assembly.FullName);
    info(assembly.Location);
    info(type.FullName);

}

Output

!

This code also works for tables and other data types. For example, for Customer Table. Just cast table to System.Object.

public static void Main(Args _args)
{
    System.Object               obj;
    System.Type                 type;
    System.Reflection.Assembly  assembly;
    
    CustTable custTable;
    obj = custTable;
    type = obj.GetType();
    assembly = type.Assembly;
    
    info(assembly.FullName);
    info(assembly.Location);
    info(type.FullName);
    
}

!

Feel free to leave a comment on twitter.

Tags:

Categories:

Updated: