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)

Interop CLR : Accessing some subclasses in AX (eg: System.TimezoneInfo.AdjustmentRule)

(0) ShareShare
ReportReport
Posted on by 510

Hi,

I'm playing with TimezoneInfo classes in .NET from AX (4.0).

I've added a AOT reference to the System.Core assembly and I'm trying to access System.TimeZoneInfo class member and methods.

It works good. But, in order to use the method TimezoneInfo.GetAdjustmentRules() I need to declare a System.TimezoneInfo.AdjustmentRule[] variable, which is that's bothering me.

I don't manage to declare even a single System.TimezoneInfo.AdjustmentRule variable. the compiler doesn't recognize the class. It seems like AX "can't see" the class behind the class. The same occurs in AX2012 (I've tested just in case it has been done some improvement on that part)

I've tested my code in C# and it works well

Do you know how to deal with these classes?

Many thanks

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,874 Most Valuable Professional on at

    I can reproduce your problem - it seems that it's simply not supported (as quite a few other "advanced" features). The workaround is simple: just wrap all such things to your own .NET library. Visual Studio projects in AOT make it much easier than ever before.

  • Nicolas GRANJON Profile Picture
    510 on at

    Hi,

    Thanks Martin for you answer

    After some research, theses classes are called Nested classes in .NET, but from AX, we can't access them directly.

    Using System.Reflection classes and System.Type, it is nevertheless possible to retrieve instances of these classes using the qualified assembly Name

    such as: System.Type::GetType("System.TimeZoneInfo+AdjustmentRule, System.Core, Version=3.5.0.0 ..."); (notice the '+' sign)

    But it gets harder to manipulate these instances using reflection. The simplier way is indeed to wrap in a .NET proxy assembly as said Martin.

    For my specific problem, it doesn't help me because I have to it in AX4.0, I'm can't (for some reasons) use custom assemblies other than the standard ones) I'll find something else... :)

    Thanks

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

    There must be a reason why your assemblies don't work. Did you build them for the right version of .NET, is the DLL deployed to the right tier and so on? I also suspect that AX 4.0 required strongly-named (= signed) assemblies, but I might be wrong.

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
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans