Base solution for your next web application

Activities of "soulmate"

Hi, Thank you. I registered it like that and the module works. HOWEVER: After one minute I receive an exception in MethodInvocationValidator and my local website (IIS) crashes:

Exception information: Exception type: HttpException Exception message: The client disconnected. at System.Web.Hosting.IIS7WorkerRequest.BeginRead(Byte[] buffer, Int32 offset, Int32 count, AsyncCallback callback, Object state) at System.Web.HttpBufferlessInputStream.BeginRead(Byte[] buffer, Int32 offset, Int32 count, AsyncCallback callback, Object state) at System.IO.Stream.<>c.<BeginEndReadAsync>b__43_0(Stream stream, ReadWriteParameters args, AsyncCallback callback, Object state) at System.Threading.Tasks.TaskFactory1.FromAsyncTrim[TInstance,TArgs](TInstance thisRef, TArgs args, Func5 beginMethod, Func`3 endMethod) at System.IO.Stream.BeginEndReadAsync(Byte[] buffer, Int32 offset, Int32 count) at System.IO.Stream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) at Microsoft.Owin.Host.SystemWeb.CallStreams.DelegatingStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) at System.IO.Stream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count) at System.IO.StreamReader.

Here is the code of the module:

[DependsOn(typeof(MyAppDataModule))]
    [DependsOn(typeof(MyAppApplicationModule))]
    [DependsOn(typeof(MyAppCoreModule))]
    [DependsOn(typeof(AbpHangfireModule))]
    public class TestModule : AbpModule
    {
        public ILogger Logger { get; set; }

        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());

            Configuration.Settings.Providers.Add&lt;TestProxySettingProvider&gt;();
            Configuration.Settings.Providers.Add&lt;QutationServicesSettingProvider&gt;();

            if (System.Diagnostics.Debugger.IsAttached)
            {
                Configuration.Auditing.IsEnabled = false;

            }
            
        }


        public override void PostInitialize()
        {
            base.PostInitialize();

            try
            {
                JobDefinition jobDefinition = new JobDefinition(IocManager);



                RecurringJob.AddOrUpdate("Provider Reminder offer 24 hours", () => jobDefinition.OfferReminderJobDefinition(24), Cron.Hourly(0));
              

            }
            catch (Exception ex)
            {
                Logger.ErrorFormat("Error in Test Module: {0}", ex);
            }
         
        }
    }

I also published the version to Azure and after 1 minute the application pool crashes.

the module worked without any troubles in the previsous version. Do you have any idea why this happen?

0.9.3

Yes, here is the code. However, the code is not hit at any time, so I think where is a filter or something like that before that prevents the execution:

[DisableAuditing]
        public ActionResult UploadFiles(IEnumerable<HttpPostedFileBase> files, int offerId)
        {
            // The Name of the Upload component is "files"
            if (files != null)
            {
                foreach (var file in files)
                {
                    var offerFile = new OfferFile();
                    var fileName = Path.GetFileName(file.FileName);

                    //Check if file exist
                    offerFile = _offerFileService.GetByNameAndOfferId(fileName, offerId) ?? new OfferFile();

                    offerFile.Name = fileName;
                    offerFile.FileType = file.ContentType;
                    offerFile.OfferId = offerId;
                    using (var binaryReader = new BinaryReader(file.InputStream))
                    {
                        offerFile.File = binaryReader.ReadBytes(file.ContentLength);
                    }

                    //Save
                    _offerFileService.Save(offerFile);
                }
            }

            // Return an empty string to signify success
            return Content("");
        }

Hi,

since it is just a sngile module/ dll I dont want to use the complete folder path here (otherwise it would iterate through all dlls). Is it possible to just add one modul?

Hello, I upgraded v0.10. I noticed that module scanning was removed <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/1167#issuecomment-229988957">https://github.com/aspnetboilerplate/as ... -229988957</a>

However, since I have a external module it is not clear for me how I can register this module explicity in the startup class. Is their any other method than using the DependsOn attribute? Something like modules.Add<MyOwnModule>();

Hello,

I have implemented a multi file upload based on a Kendo UI component. Here is my method:

[DisableAuditing]
        public ActionResult UploadFiles(IEnumerable<HttpPostedFileBase> files, int offerId)
        {
...
}

It worked without any problem. However, I upgraded to v0.10.0.2 and now I receive following error:

Server Error in '/' Application.

Timeouts are not supported on this stream. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Timeouts are not supported on this stream.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidOperationException: Timeouts are not supported on this stream.] System.IO.Stream.get_ReadTimeout() +57

[TargetInvocationException: Property accessor 'ReadTimeout' on object 'System.Web.HttpInputStream' threw the following exception:'Timeouts are not supported on this stream.'] System.ComponentModel.ReflectPropertyDescriptor.GetValue(Object component) +525 Abp.Runtime.Validation.Interception.MethodInvocationValidator.ValidateObjectRecursively(Object validatingObject) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Runtime\Validation\Interception\MethodInvocationValidator.cs:192 Abp.Runtime.Validation.Interception.MethodInvocationValidator.ValidateObjectRecursively(Object validatingObject) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Runtime\Validation\Interception\MethodInvocationValidator.cs:185 Abp.Runtime.Validation.Interception.MethodInvocationValidator.ValidateObjectRecursively(Object validatingObject) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Runtime\Validation\Interception\MethodInvocationValidator.cs:154 Abp.Runtime.Validation.Interception.MethodInvocationValidator.Validate() in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Runtime\Validation\Interception\MethodInvocationValidator.cs:85 Abp.Web.Mvc.Validation.AbpMvcValidationFilter.OnActionExecuting(ActionExecutingContext filterContext) in D:\Halil\GitHub\aspnetboilerplate\src\Abp.Web.Mvc\Web\Mvc\Validation\AbpMvcValidationFilter.cs:27 System.Web.Mvc.Async.AsyncInvocationWithFilters.InvokeActionMethodFilterAsynchronouslyRecursive(Int32 filterIndex) +268 System.Web.Mvc.Async.AsyncInvocationWithFilters.InvokeActionMethodFilterAsynchronouslyRecursive(Int32 filterIndex) +1079 System.Web.Mvc.Async.AsyncInvocationWithFilters.InvokeActionMethodFilterAsynchronouslyRecursive(Int32 filterIndex) +1079 System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__31(AsyncCallback asyncCallback, Object asyncState) +93 System.Web.Mvc.Async.WrappedAsyncResultBase1.Begin(AsyncCallback callback, Object state, Int32 timeout) +170 System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeActionMethodWithFilters(ControllerContext controllerContext, IList1 filters, ActionDescriptor actionDescriptor, IDictionary2 parameters, AsyncCallback callback, Object state) +292 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__19(AsyncCallback asyncCallback, Object asyncState) +1167 System.Web.Mvc.Async.WrappedAsyncResultBase1.Begin(AsyncCallback callback, Object state, Int32 timeout) +170 System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +455 System.Web.Mvc.Controller.<BeginExecuteCore>b__1c(AsyncCallback asyncCallback, Object asyncState, ExecuteCoreState innerState) +42 System.Web.Mvc.Async.WrappedAsyncVoid1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +67 System.Web.Mvc.Async.WrappedAsyncResultBase1.Begin(AsyncCallback callback, Object state, Int32 timeout) +170 System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +897 System.Web.Mvc.Async.WrappedAsyncResultBase1.Begin(AsyncCallback callback, Object state, Int32 timeout) +170 System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +711 System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__4(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState) +94 System.Web.Mvc.Async.WrappedAsyncVoid1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +67 System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +170 System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +575 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +923 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +137

How can I fix this one?

The application is alive and azure is configured to dont shut down. The problem exist randomly if I start debugging or deploy a new version. I think for some reasons it randomly failed to register the dependencies

Hi hikalkan,

During the last month I traced the issue a lot. However, I cant find the root of the problem. Here is my scenario:

  1. I debug (on my local IIS) or deploy the application to azure
  2. Azure app service is configured to dont shut down
  3. When using hangfire and the job is executed and sometime I receive the mentioned error and sometime it works (50/50 chance)
  4. When the error appear I restart the iis. Sometimes it works and sometimes not.

Do you have any idea how to get rid of it?

Hi,

No, I have no dependency to MyModule. The project is a class library, that is deployed via the web application that comes with the template. MyModule implements AbpModule. The main goal of the module is to execute recurring jobs (some should execute every 2 minutes, some every hour). The jobs are registered in hangfire and access code in .Application project. It is strange because the jobs run fine for 30 minutes. After that it seems like castle "forget" the reference.

I have done some refectoring to make the problem more clear. I seperate the job into an own class:

public class JobDefinition : ITransientDependency
    {
        private readonly IIocResolver _iocResolver;

        public JobDefinition(IIocResolver iocResolver)
        {
            _iocResolver = iocResolver;
        }

        [DisplayName("Import qutations from url {0}")]
        [AutomaticRetry(Attempts = 0, OnAttemptsExceeded = AttemptsExceededAction.Delete)]
        public void QutationImportServiceJobDefinition(string tenant, string url)
        {
            var qutationImportService = _iocResolver.Resolve<IQutationImportService>();
            qutationImportService.Start(tenant, url);
        }
    }

Here is the definition of the module:

[DependsOn(typeof(AbpHangfireModule))]
    public class MyModule : AbpModule
    {
        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
       

            Configuration.BackgroundJobs.UseHangfire(
                configuration => { configuration.GlobalConfiguration.UseSqlServerStorage("Default"); });
        }


        public override void PostInitialize()
        {
            base.PostInitialize();

            var jobDefinition = new JobDefinition(IocManager);


                //Every 2 minutes
                RecurringJob.AddOrUpdate($"Job for {tenant}",
                    () => jobDefinition.QutationImportServiceJobDefinition("---", "http://google.com"),
                    "*/2 * * * *");
         
        }
    }

The exception is:

JobDefinition jobDefinition = Activate<JobDefinition>(); jobDefinition.QutationImportServiceJobDefinition();

Failed An exception occurred during processing of a background job.

Castle.MicroKernel.ComponentNotFoundException

No component for supporting the service JobDefinition was found Castle.MicroKernel.ComponentNotFoundException: No component for supporting the service JobDefinition was found at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, IDictionary arguments, IReleasePolicy policy) at Castle.MicroKernel.DefaultKernel.Resolve(Type service, IDictionary arguments) at Castle.Windsor.WindsorContainer.Resolve(Type service) at Abp.Dependency.IocManager.Resolve(Type type) at Abp.Hangfire.HangfireIocJobActivator.ActivateJob(Type jobType) at Abp.Hangfire.HangfireIocJobActivator.HangfireIocJobActivatorScope.Resolve(Type type) at Hangfire.Server.CoreBackgroundJobPerformer.Perform(PerformContext context) at Hangfire.Server.BackgroundJobPerformer.<>c__DisplayClass8_0.<PerformJobWithFilters>b__0() at Hangfire.Server.BackgroundJobPerformer.InvokePerformFilter(IServerFilter filter, PerformingContext preContext, Func1 continuation) at Hangfire.Server.BackgroundJobPerformer.<>c__DisplayClass8_1.<PerformJobWithFilters>b__2() at Hangfire.Server.BackgroundJobPerformer.PerformJobWithFilters(PerformContext context, IEnumerable1 filters) at Hangfire.Server.BackgroundJobPerformer.Perform(PerformContext context) at Hangfire.Server.Worker.PerformJob(BackgroundProcessContext context, IStorageConnection connection, String jobId)

The application runs on the latest version of ABP. The secneario is the same deployed to my local IIS/ to azure. The application is set to "run always".

Do you have any idea why it "forgets" the reference? If you have any other idea how to register jobs in a seperate module that are executed with hangfire I can also follow this guidance.

Hello,

I have following problem: I created a module based on the AbpModule. In that module I like to configure recurring jobs with hangfire. A recurring job in this scenario notifies users. I have following code:

[DependsOn(typeof(AbpHangfireModule))]
    public class MyModule : AbpModule
    {
        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
          

            Configuration.BackgroundJobs.UseHangfire(
                configuration => { configuration.GlobalConfiguration.UseSqlServerStorage("Default"); });
        }

     
        [DisplayName("Provider Reminder for offers that are due {0} hours")]
        [AutomaticRetry(Attempts = 0, OnAttemptsExceeded = AttemptsExceededAction.Delete)]
        public void OfferReminderJobDefinition(int hours)
        {
            var reminderService = IocManager.Resolve<IReminderService>();
            reminderService.Start(hours);
        }


        public override void PostInitialize()
        {
            base.PostInitialize();

                   
            RecurringJob.AddOrUpdate("Provider Reminder offer 24 hours", () => OfferReminderJobDefinition(24), Cron.Hourly);
            RecurringJob.AddOrUpdate("Provider Reminder offer 36 hours", () => OfferReminderJobDefinition(36), Cron.Hourly);


        }
    }

The implementation of the IReminder Service looks like:

public class ReminderService : AppServiceBase, IReminderService
    {
        /// <summary>
        /// The _offer service
        /// </summary>
        private readonly IOfferService _offerService;
        /// <summary>
        /// The _offer executed action service
        /// </summary>
        private readonly IOfferExecutedActionService _offerExecutedActionService;

        /// <summary>
        /// The _qutation service
        /// </summary>
        private readonly IQutationService _qutationService;
        /// <summary>
        /// The _routing parameter service
        /// </summary>
        private readonly IRoutingParameterService _routingParameterService;

        private readonly IOfferEmailer _offerEmailer;



        /// <summary>
        /// The _tenant identifier
        /// </summary>
        private readonly int _tenantId = 1;


        /// <summary>
        /// Initializes a new instance of the <see cref="ReminderService"/> class.
        /// </summary>
        /// <param name="qutationService">The qutation service.</param>
        /// <param name="offerService">The offer service.</param>
        /// <param name="offerExecutedActionService">The offer executed action service.</param>
        /// <param name="offerEmailer"></param>
        public ReminderService(IQutationService qutationService, IOfferService offerService,
         IOfferExecutedActionService offerExecutedActionService, IOfferEmailer offerEmailer)
        {
            _qutationService = qutationService;
            _offerExecutedActionService = offerExecutedActionService;
            _offerService = offerService;
            _offerEmailer = offerEmailer;

        }


        /// <summary>
        /// Starts the specified hours.
        /// </summary>
        /// <param name="hours">The hours.</param>
        public async void Start(int hours)
        {
            await ProcessReminder(hours);
        }
        ...
    }

When I start the application the job is registered correct in hangfire. Also the first call/ job execution works without any problems. However, the next execution fails with following error:

Failed An exception occurred during processing of a background job.

Castle.MicroKernel.ComponentNotFoundException

No component for supporting the service MyModule was found Castle.MicroKernel.ComponentNotFoundException: No component for supporting the service MyModule was found at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, IDictionary arguments, IReleasePolicy policy) at Castle.MicroKernel.DefaultKernel.Resolve(Type service, IDictionary arguments) at Castle.Windsor.WindsorContainer.Resolve(Type service) at Abp.Dependency.IocManager.Resolve(Type type) at Abp.Hangfire.HangfireIocJobActivator.ActivateJob(Type jobType) at Abp.Hangfire.HangfireIocJobActivator.HangfireIocJobActivatorScope.Resolve(Type type) at Hangfire.Server.CoreBackgroundJobPerformer.Perform(PerformContext context) at Hangfire.Server.BackgroundJobPerformer.<>c__DisplayClass8_0.<PerformJobWithFilters>b__0() at Hangfire.Server.BackgroundJobPerformer.InvokePerformFilter(IServerFilter filter, PerformingContext preContext, Func1 continuation) at Hangfire.Server.BackgroundJobPerformer.<>c__DisplayClass8_1.<PerformJobWithFilters>b__2() at Hangfire.Server.BackgroundJobPerformer.PerformJobWithFilters(PerformContext context, IEnumerable1 filters) at Hangfire.Server.BackgroundJobPerformer.Perform(PerformContext context) at Hangfire.Server.Worker.PerformJob(BackgroundProcessContext context, IStorageConnection connection, String jobId)

It looks like as if the Module forget the dependency. Do you know why that happens and how I can get rid of it?

Showing 11 to 20 of 33 entries