We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

OutOfMemoryException when using .NET 6

Much like this topic: OutOfMemoryException when saving Appointment - Aspose.Email Product Family - Free Support Forum - aspose.com .NET 6 seems to cause issues when using Aspose.Email (21.12.0).

Given a very simple Console app such as:

static void Main(string[] args)
        {
            var asposeAppointment = new Aspose.Email.Calendar.Appointment("",
                                                                            DateTime.UtcNow.AddHours(1),
                                                                            DateTime.UtcNow.AddHours(2),
                                                                            new MailAddress("a@b.com"),
                                                                            new MailAddressCollection());

            Console.WriteLine(asposeAppointment.GetAppointmentText());

            asposeAppointment.SetTimeZone("Etc/UTC");
        }
    }

The SetTimeZone line throws the following:

System.TypeInitializationException
  HResult=0x80131534
  Message=The type initializer for '   ' threw an exception.
  Source=Aspose.Email
  StackTrace:
   at    .(String )
   at Aspose.Email.Calendar.Appointment.(String )
   at Aspose.Email.Calendar.Appointment.set_StartTimeZone(String value)
   at Aspose.Email.Calendar.Appointment.SetTimeZone(String tzName)
   at AsposeEmailOOM.Program.Main(String[] args) in D:\source\repos\AsposeEmailOOM\AsposeEmailOOM\Program.cs:line 18

  This exception was originally thrown at this call stack:
    [External Code]

Inner Exception 1:
OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.

If I switch this simple Console app to .NET 5 the program runs without issue.

It’s not just SetTimeZone that throws such as error when using .NET 6, RequestApointment(0) throws a similar but not identical error:

System.TypeInitializationException
  HResult=0x80131534
  Message=The type initializer for '  ' threw an exception.
  Source=Aspose.Email
  StackTrace:
   at   .()
   at   ..ctor(DateTime , Boolean )
   at   .(DateTime )
   at   .(Appointment )
   at   .()
   at   .      ()
   at Aspose.Email.Calendar.CalendarWriter.Write(Appointment appointment)
   at Aspose.Email.Calendar.Appointment.(AppointmentIcsSaveOptions )
   at Aspose.Email.Calendar.Appointment.RequestApointment(Int32 seqId)
   at AsposeEmailOOM.Program.Main(String[] args) in D:\source\repos\AsposeEmailOOM\AsposeEmailOOM\Program.cs:line 18

  This exception was originally thrown at this call stack:
    [External Code]

Inner Exception 1:
TypeInitializationException: The type initializer for '   ' threw an exception.

Inner Exception 2:
OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
1 Like

@Martyn_Swanick

We have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as EMAILNET-40502. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.