Cannot use System.DateTime::ParseExact method due to error Method 'ParseExact(System.String, System.String)' is not found on type 'System.DateTime'

Hi,

I am unable to use the method System.DateTime::ParseExact. It shows the error: Method ‘ParseExact(System.String, System.String)’ is not found on type ‘System.DateTime’. This type of error looks like missing reference.

I checked AOT reference System, it is using ApplicationPlatform and TestEssentials packages. I have add both as reference to my model. I have run full build.

not only ParseExact method is affected, I cannot use any of the methods from DateTime class.

This is the code that I am using:

System.DateTime::ParseExact(‘1993Dec090202’,‘yyyyMMMddHHmm’)

Installed product version : Microsoft Dynamics 365 for Finance and Operations (7.3)
Installed platform version : Update15 (7.0.4841.41301)

Do you think we should not use this functionality anymore?
Is there something else we can use instead?
Should I add any additional references ?

I would happy to hear any suggestions. Thanks in advance

No, System is not using ApplicationPlatform or TestEssentials. It’s a namespace in the .NET base class library; it has no reference to Dynamics.

The problem is that there is no overload of ParseExact() accepting two strings (without any extra parameter). These are your options:

  • ParseExact(String, String, IFormatProvider)
  • ParseExact(String, String, IFormatProvider, DateTimeStyles)
  • ParseExact(String, String[], IFormatProvider, DateTimeStyles)

You can do this, for example:

System.Globalization.CultureInfo culture = System.Globalization.CultureInfo::CurrentCulture;
utcDateTime dt = System.DateTime::ParseExact('1993Dec090202','yyyyMMMddHHmm', culture);

Thanks,

That worked. Not sure how i missed that [emoticon:c4563cd7d5574777a71c318021cbbcc8]