eXpandFramework / eXpand

DevExpress XAF (eXpressApp) extension framework. 𝗹𝗶𝗻𝗸𝗲𝗱𝗶𝗻.𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸.𝗰𝗼𝗺, 𝘆𝗼𝘂𝘁𝘂𝗯𝗲.𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸.𝗰𝗼𝗺 and 𝘁𝘄𝗶𝘁𝘁𝗲𝗿 @𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸 and or simply 𝗦𝘁𝗮𝗿/𝘄𝗮𝘁𝗰𝗵 this repository and get notified from 𝗚𝗶𝘁𝗛𝘂𝗯
http://expand.expandframework.com
Microsoft Public License
221 stars 115 forks source link

Using JobScheduler.Hangfire module, XAF Blazor application crash when opening Workers tab of Hangire Job #978

Closed ss-carlo closed 1 year ago

ss-carlo commented 1 year ago

Hi,

While in the details view of the Hangfire Job, when I try to open the Workers tab, the application suddenly crashes with the following error message:

`The error occurred:

Type:       NullReferenceException
Message:    Object reference not set to an instance of an object.
Data:       0 entries
Stack trace:

at Xpand.XAF.Modules.Reactive.Services.AttributesExtensions.<>c.b__24(ValueTuple2 t) at System.Linq.EnumerableEx.DoCore[TSource](IEnumerable1 source, Action1 onNext, Action1 onError, Action onCompleted)+MoveNext() in //Ix.NET/Source/System.Interactive/System/Linq/Operators/Do.cs:line 129 at System.Linq.Enumerable.SelectManySingleSelectorIterator2.MoveNext() at System.Reactive.Linq.ObservableImpl.SelectMany2.EnumerableSelector..OnNext(TSource value) in //Rx.NET/Source/src/System.Reactive/Linq/Observable/SelectMany.cs:line 1361 InnerException is null`

Sample video: https://user-images.githubusercontent.com/55209461/217061893-595240bd-0760-45ec-ad51-8da3930ea95c.mp4

apobekiaris commented 1 year ago

post your sample

ss-carlo commented 1 year ago

Here is the sample project

Sample

apobekiaris commented 1 year ago

The pre-release 4.222.2.0 in the Reactive.XAF lab branch includes commits that relate to this task:

To minimize version conflicts we recommend that you use the Xpand.XAF.Core.All, Xpand.XAF.Win.All, Xpand.XAF.Web.All packages. Doing so, all packages will be at your disposal and .NET will add a dependecy only to those packages that you actually use and not to all (see the Modules installation-registrations youtube video).

Released packages: Xpand.Extensions v.4.222.2
Xpand.Extensions.Blazor v.4.222.2
Xpand.Extensions.Mono.Cecil v.4.222.2
Xpand.Extensions.Office.Cloud v.4.222.2
Xpand.Extensions.Office.Cloud.Google.Blazor v.4.222.2
Xpand.Extensions.Reactive v.4.222.2
Xpand.Extensions.XAF v.4.222.2
Xpand.Extensions.XAF.Xpo v.4.222.2
Xpand.TestsLib v.4.222.2
Xpand.TestsLib.Blazor v.4.222.2
Xpand.TestsLib.Common v.4.222.2
Xpand.TestsLib.EasyTest v.4.222.2
Xpand.VersionConverter v.4.222.2
Xpand.XAF.Core.All v.4.222.2
Xpand.XAF.Modules.AutoCommit v.4.222.2
Xpand.XAF.Modules.Blazor v.4.222.2
Xpand.XAF.Modules.BulkObjectUpdate v.4.222.2
Xpand.XAF.Modules.CloneMemberValue v.4.222.2
Xpand.XAF.Modules.CloneModelView v.4.222.2
Xpand.XAF.Modules.Email v.4.222.2
Xpand.XAF.Modules.GridListEditor v.4.222.2
Xpand.XAF.Modules.HideToolBar v.4.222.2
Xpand.XAF.Modules.JobScheduler.Hangfire v.4.222.2
Xpand.XAF.Modules.JobScheduler.Notification v.4.222.2
Xpand.XAF.Modules.MasterDetail v.4.222.2
Xpand.XAF.Modules.ModelMapper v.4.222.2
Xpand.XAF.Modules.ModelViewInheritance v.4.222.2
Xpand.XAF.Modules.Office.Cloud.Google v.4.222.2
Xpand.XAF.Modules.Office.Cloud.Google.Calendar v.4.222.2
Xpand.XAF.Modules.Office.Cloud.Google.Tasks v.4.222.2
Xpand.XAF.Modules.Office.DocumentStyleManager v.4.222.2
Xpand.XAF.Modules.OneView v.4.222.2
Xpand.XAF.Modules.PositionInListView v.4.222.2
Xpand.XAF.Modules.ProgressBarViewItem v.4.222.2
Xpand.XAF.Modules.RazorView v.4.222.2
Xpand.XAF.Modules.Reactive v.4.222.2
Xpand.XAF.Modules.Reactive.Logger v.4.222.2
Xpand.XAF.Modules.Reactive.Logger.Client.Win v.4.222.2
Xpand.XAF.Modules.Reactive.Logger.Hub v.4.222.2
Xpand.XAF.Modules.Reactive.Rest v.4.222.2
Xpand.XAF.Modules.RefreshView v.4.222.2
Xpand.XAF.Modules.SequenceGenerator v.4.222.2
Xpand.XAF.Modules.Speech v.4.222.2
Xpand.XAF.Modules.SpellChecker v.4.222.2
Xpand.XAF.Modules.StoreToDisk v.4.222.2
Xpand.XAF.Modules.SuppressConfirmation v.4.222.2
Xpand.XAF.Modules.TenantManager v.4.222.2
Xpand.XAF.Modules.ViewEditMode v.4.222.2
Xpand.XAF.Modules.ViewItemValue v.4.222.2
Xpand.XAF.Modules.ViewWizard v.4.222.2
Xpand.XAF.Modules.Windows v.4.222.2
Xpand.XAF.Web.All v.4.222.2
Xpand.XAF.Win.All v.4.222.2

Please update the related Nuget packages and test if issues is addressed. These are nightly nuget packages available only from our NugetServer.

If you do not use these packages directly but through a module of the main eXpandFramework project, please wait for the bot to notify you again when integration is finished or update the related packages manually.

Thanks a lot for your contribution.

ss-carlo commented 1 year ago

Hi @apobekiaris,

I have updated my DevExpress version to 22.2.4 to be able to use the pre-release Nuget packages. I also used the Xpand.XAF.Core.All and Xpand.XAF.Web.All as recommended but it still did not fix the issue. It actually made the Blazor application crash when I try to navigate into the JobScheduler menu Sample Video

Here is the new error message: `The error occurred:

Type:       ArgumentNullException
Message:    Value cannot be null. (Parameter 'context')
Data:       0 entries
Stack trace:

at System.Reactive.Linq.Observable.ObserveOn[TSource](IObservable1 source, SynchronizationContext context) in /_/Rx.NET/Source/src/System.Reactive/Linq/Observable.Concurrency.cs:line 62 at Xpand.XAF.Modules.Reactive.Services.XafApplicationRxExtensions.WhenWindowCreated(XafApplication application, Boolean isMain, Boolean emitIfMainExists) at Xpand.XAF.Modules.Reactive.Services.XafApplicationRxExtensions.WhenSynchronizationContext(XafApplication application) at Xpand.XAF.Modules.Reactive.Services.ShowMessageExtensions.ShowMessages(XafApplication application) at Xpand.XAF.Modules.Reactive.RxApp.Connect(XafApplication application) at Xpand.XAF.Modules.Reactive.RxApp.<>c__DisplayClass12_0.<Connect>b__0(XafApplication application) at System.Reactive.Linq.ObservableImpl.Defer1..Run() in //Rx.NET/Source/src/System.Reactive/Linq/Observable/Defer.cs:line 37 InnerException is null`

Thanks

apobekiaris commented 1 year ago

Using the next minor I did:

  1. New Wizard Blazor solution
  2. Add the next in the blazor project
    <PackageReference Include="Xpand.XAF.Modules.JobScheduler.Hangfire" Version="4.222.2.1" />
    <PackageReference Include="Hangfire.MemoryStorage" Version="1.7.0" />
  3. Added the next in the BlazorModule.cs

[assembly: HostingStartup(typeof(HostingStartup))] [assembly: HostingStartup(typeof(HangfireStartup))] [assembly: HostingStartup(typeof(Xpand.XAF.Modules.Blazor.BlazorStartup))] namespace DXApplication26.Blazor.Server;

[JobProvider] public class Job { public IServiceProvider ServiceProvider { get; } public Job() { } [ActivatorUtilitiesConstructor] public Job(IServiceProvider provider) => ServiceProvider = provider;

[JobProvider]
public async Task<bool> ImportOrders() 
    => await ServiceProvider.RunWithStorageAsync(application => Observable.Using(
        () => application.CreateNonSecuredObjectSpace(typeof(Order)),objectSpace 
            => Observable.Range(0, 10).Do(i => {
                var order = objectSpace.CreateObject<Order>();
                order.OrderID = i;
            }).Finally(objectSpace.CommitChanges)).To(true));

public void Failed() {
    throw new NotImplementedException();
}

}

public class Order:BaseObject { public Order(Session session) : base(session) { }

int _orderID;

public int OrderID {
    get => _orderID;
    set => SetPropertyValue(nameof(OrderID), ref _orderID, value);
}

}

4. In the same file
```cs
public DXApplication26BlazorModule() {
       RequiredModuleTypes.Add(typeof(JobSchedulerModule));
    }
    public override void AddGeneratorUpdaters(ModelNodesGeneratorUpdaters updaters) {
        base.AddGeneratorUpdaters(updaters);
        updaters.Add(new JoSchedulerSourceUpdater());
    }
  1. Setup a Hangfire storage in Startup.cs
    GlobalConfiguration.Configuration.UseMemoryStorage();

Doing so I was able to create and trigger a new job and open the Workers tab.

apobekiaris commented 1 year ago

The pre-release 4.222.2.0 in the Reactive.XAF lab branch includes commits that relate to this task:

To minimize version conflicts we recommend that you use the Xpand.XAF.Core.All, Xpand.XAF.Win.All, Xpand.XAF.Web.All packages. Doing so, all packages will be at your disposal and .NET will add a dependecy only to those packages that you actually use and not to all (see the Modules installation-registrations youtube video).

Released packages: Xpand.Extensions v.4.222.2
Xpand.Extensions.Blazor v.4.222.2
Xpand.Extensions.Mono.Cecil v.4.222.2
Xpand.Extensions.Office.Cloud v.4.222.2
Xpand.Extensions.Office.Cloud.Google.Blazor v.4.222.2
Xpand.Extensions.Reactive v.4.222.2
Xpand.Extensions.XAF v.4.222.2
Xpand.Extensions.XAF.Xpo v.4.222.2
Xpand.TestsLib v.4.222.2
Xpand.TestsLib.Blazor v.4.222.2
Xpand.TestsLib.Common v.4.222.2
Xpand.TestsLib.EasyTest v.4.222.2
Xpand.VersionConverter v.4.222.2
Xpand.XAF.Core.All v.4.222.2
Xpand.XAF.Modules.AutoCommit v.4.222.2
Xpand.XAF.Modules.Blazor v.4.222.2
Xpand.XAF.Modules.BulkObjectUpdate v.4.222.2
Xpand.XAF.Modules.CloneMemberValue v.4.222.2
Xpand.XAF.Modules.CloneModelView v.4.222.2
Xpand.XAF.Modules.Email v.4.222.2
Xpand.XAF.Modules.GridListEditor v.4.222.2
Xpand.XAF.Modules.HideToolBar v.4.222.2
Xpand.XAF.Modules.JobScheduler.Hangfire v.4.222.2
Xpand.XAF.Modules.JobScheduler.Notification v.4.222.2
Xpand.XAF.Modules.MasterDetail v.4.222.2
Xpand.XAF.Modules.ModelMapper v.4.222.2
Xpand.XAF.Modules.ModelViewInheritance v.4.222.2
Xpand.XAF.Modules.Office.Cloud.Google v.4.222.2
Xpand.XAF.Modules.Office.Cloud.Google.Calendar v.4.222.2
Xpand.XAF.Modules.Office.Cloud.Google.Tasks v.4.222.2
Xpand.XAF.Modules.Office.DocumentStyleManager v.4.222.2
Xpand.XAF.Modules.OneView v.4.222.2
Xpand.XAF.Modules.PositionInListView v.4.222.2
Xpand.XAF.Modules.ProgressBarViewItem v.4.222.2
Xpand.XAF.Modules.RazorView v.4.222.2
Xpand.XAF.Modules.Reactive v.4.222.2
Xpand.XAF.Modules.Reactive.Logger v.4.222.2
Xpand.XAF.Modules.Reactive.Logger.Client.Win v.4.222.2
Xpand.XAF.Modules.Reactive.Logger.Hub v.4.222.2
Xpand.XAF.Modules.Reactive.Rest v.4.222.2
Xpand.XAF.Modules.RefreshView v.4.222.2
Xpand.XAF.Modules.SequenceGenerator v.4.222.2
Xpand.XAF.Modules.Speech v.4.222.2
Xpand.XAF.Modules.SpellChecker v.4.222.2
Xpand.XAF.Modules.StoreToDisk v.4.222.2
Xpand.XAF.Modules.SuppressConfirmation v.4.222.2
Xpand.XAF.Modules.TenantManager v.4.222.2
Xpand.XAF.Modules.ViewEditMode v.4.222.2
Xpand.XAF.Modules.ViewItemValue v.4.222.2
Xpand.XAF.Modules.ViewWizard v.4.222.2
Xpand.XAF.Modules.Windows v.4.222.2
Xpand.XAF.Web.All v.4.222.2
Xpand.XAF.Win.All v.4.222.2

Please update the related Nuget packages and test if issues is addressed. These are nightly nuget packages available only from our NugetServer.

If you do not use these packages directly but through a module of the main eXpandFramework project, please wait for the bot to notify you again when integration is finished or update the related packages manually.

Thanks a lot for your contribution.

ss-carlo commented 1 year ago

Using the next minor I did:

  1. New Wizard Blazor solution
  2. Add the next in the blazor project
    <PackageReference Include="Xpand.XAF.Modules.JobScheduler.Hangfire" Version="4.222.2.1" />
    <PackageReference Include="Hangfire.MemoryStorage" Version="1.7.0" />
  3. Added the next in the BlazorModule.cs
[assembly: HostingStartup(typeof(HostingStartup))]
[assembly: HostingStartup(typeof(HangfireStartup))]
[assembly: HostingStartup(typeof(Xpand.XAF.Modules.Blazor.BlazorStartup))]
namespace DXApplication26.Blazor.Server;

[JobProvider]
public class Job {
  public IServiceProvider ServiceProvider { get; }
  public Job() { }
  [ActivatorUtilitiesConstructor]
  public Job(IServiceProvider provider) => ServiceProvider = provider;

  [JobProvider]
  public async Task<bool> ImportOrders() 
      => await ServiceProvider.RunWithStorageAsync(application => Observable.Using(
          () => application.CreateNonSecuredObjectSpace(typeof(Order)),objectSpace 
              => Observable.Range(0, 10).Do(i => {
                  var order = objectSpace.CreateObject<Order>();
                  order.OrderID = i;
              }).Finally(objectSpace.CommitChanges)).To(true));

  public void Failed() {
      throw new NotImplementedException();
  }

}

public class Order:BaseObject {
  public Order(Session session) : base(session) {
  }

  int _orderID;

  public int OrderID {
      get => _orderID;
      set => SetPropertyValue(nameof(OrderID), ref _orderID, value);
  }
}   
  1. In the same file
public DXApplication26BlazorModule() {
       RequiredModuleTypes.Add(typeof(JobSchedulerModule));
    }
    public override void AddGeneratorUpdaters(ModelNodesGeneratorUpdaters updaters) {
      base.AddGeneratorUpdaters(updaters);
      updaters.Add(new JoSchedulerSourceUpdater());
    }
  1. Setup a Hangfire storage in Startup.cs
GlobalConfiguration.Configuration.UseMemoryStorage();

Doing so I was able to create and trigger a new job and open the Workers tab.

Thanks, I can confirm that this minor version fixes the issue!