I am porting an ASP.NET MVC 5 application from the .NET Framework to Mono.
The last border gets the work of HostingEnvironment.QueueBackgroundWorkItem.
The application runs on Apache mod_mono, in the docker container.
As the title says, HostingEnvironment.QueueBackgroundWorkItem throws an InvalidOperationException. Below is a complete stack trace.
System.InvalidOperationException: Operation is not valid due to the current state of the object.
at System.Web.Hosting.HostingEnvironment.QueueBackgroundWorkItem (System.Func`2[T,TResult] workItem) [0x00015] in <347f335902b24586a53361aa1278a360>:0
at System.Web.Hosting.HostingEnvironment.QueueBackgroundWorkItem (System.Action`1[T] workItem) [0x00005] in <347f335902b24586a53361aa1278a360>:0
at Ayyeka.Web.UI.Utils.DashboardModelBuilder.SaveModelToCache (Ayyeka.Web.UI.Models.AdminManagementModel model, System.UInt64 userId, System.String token) [0x00005] in <94931e6f7d3d48188e8c013f1bec6e2a>:0
at Ayyeka.Web.UI.Utils.DashboardModelBuilder.build (System.String userUiRole, System.UInt64 userId, System.String token, Ayyeka.Web.UI.BackendUser.User user, System.Boolean cacheModel) [0x004a1] in <94931e6f7d3d48188e8c013f1bec6e2a>:0
I tried to trace the error in the mono source and probably comes down to the marked line in the following way:
public static void QueueBackgroundWorkItem(Func<CancellationToken, Task> workItem) {
if (workItem == null) {
throw new ArgumentNullException("workItem");
}
if (Host == null) {
throw new InvalidOperationException();
}
QueueBackgroundWorkItemInternal(workItem);
}
Why is Host null? Is my mod_mono configured so that everything fails in ASP.NET AppDomain? Or is it not supported?
Thank.
source
share