C# 我该如何解决一个问题;缺少委托编组数据“;.NET Core中的DateTime.ToString()出错?

C# 我该如何解决一个问题;缺少委托编组数据“;.NET Core中的DateTime.ToString()出错?,c#,datetime,.net-core,datetime-format,C#,Datetime,.net Core,Datetime Format,我写这个程序是为了尽量减少错误再现: using System; namespace HelloDates { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); var today = DateTime.Today; Console.WriteLine("I

我写这个程序是为了尽量减少错误再现:

using System;

namespace HelloDates
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            var today = DateTime.Today;
            Console.WriteLine("I know what day it is!");
            string today_fmt = today.ToString("MM/dd/yyyy");
            Console.WriteLine($"Today is {today_fmt}.");
        }
    }
}
添加了Microsoft.DotNet.ILCompiler,与CoreRT一起发布,运行后得到以下结果:

Hello World!
I know what day it is!
Unhandled Exception: EETypeRva:0x00283B48: EETypeRva:0x00295C98 is missing delegate marshalling data. To enable delegate marshalling data, add a MarshalDelegate directive to the application rd.xml file. For more information, please visit http://go.microsoft.com/fwlink/?LinkID=393965
   at HelloDates!<BaseAddress>+0x5fed
   at HelloDates!<BaseAddress>+0xfddcf
   at HelloDates!<BaseAddress>+0x1458fb
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.GetValue(TKey, ConditionalWeakTable`2.CreateValueCallback) + 0x3d
   at System.Runtime.InteropServices.PInvokeMarshal.GetFunctionPointerForDelegate(Delegate) + 0x83
   at HelloDates!<BaseAddress>+0xb6c38
   at HelloDates!<BaseAddress>+0xb9ab8
   at System.Globalization.DateTimeFormatInfo.set_Calendar(Calendar) + 0x94
   at System.Globalization.CultureInfo.get_DateTimeFormat() + 0x57
   at System.Globalization.CultureInfo.GetFormat(Type) + 0x88
   at System.Globalization.DateTimeFormatInfo.get_CurrentInfo() + 0x50
   at System.Globalization.DateTimeFormatInfo.GetInstance(IFormatProvider) + 0x8b
   at HelloDates!<BaseAddress>+0x9b630
   at HelloDates!<BaseAddress>+0x9b4bd
   at HelloDates.Program.Main(String[]) + 0x62
   at HelloDates!<BaseAddress>+0x155416
你好,世界!
我知道今天是什么日子!
未处理的异常:EETypeRva:0x00283B48:EETypeRva:0x00295C98缺少委托编组数据。要启用委托封送数据,请向应用程序rd.xml文件添加MarshallDelegate指令。欲了解更多信息,请访问http://go.microsoft.com/fwlink/?LinkID=393965
在HelloDates+0x5fed
在HelloDates+0xfddcf
在HelloDates+0x1458fb
在System.Runtime.CompilerServices.ConditionalWeakTable`2.GetValue(TKey,ConditionalWeakTable`2.CreateValueCallback)+0x3d
在System.Runtime.InteropServices.PInvokeMarshal.GetFunctionPointerForDelegate(委托)+0x83
在HelloDates+0xb6c38
在HelloDates+0xb9ab8
在System.Globalization.DateTimeFormatInfo.set_Calendar(Calendar)+0x94
在System.Globalization.CultureInfo.get_DateTimeFormat()+0x57
位于System.Globalization.CultureInfo.GetFormat(类型)+0x88
在System.Globalization.DateTimeFormatInfo.get_CurrentInfo()+0x50
位于System.Globalization.DateTimeFormatInfo.GetInstance(IFormatProvider)+0x8b
在HelloDates+0x9b630
在HelloDates+0x9b4bd
在HelloDates.Program.Main(字符串[])处+0x62
在HelloDates+0x155416
显然,当程序试图格式化日期时会出现错误。但我不知道什么是委托编组数据或EETypeRva,我在任何地方都看不到rd.xml文件,而且我无法理解链接的文档。关于反思


特别令人沮丧的是,在我最初遇到错误的早期版本的程序中,ToString()工作得很好,甚至编译为本机代码,我也不知道可能发生了什么变化。

依靠今天的CoreRT,呃,是勇敢的。顺便说一句,理解rd.xml的重要性非常重要。但是对于框架类型,您不应该需要它,请单击以让他们知道。在检查它是否不是特定于您所在地区的日历问题后,请先使用en-US进行测试。一定要完成你的SO档案,这样我们才能知道你来自哪里。