quartz.net - ServiceStack.Funq.Quartz cannot instantiating type? -


servicestack.funq.quartz sample code

public class myservices : service {     public object any(hello request)     {         return new helloresponse { result = "hello, {0}!".fmt(request.name) };     } }  public class hellojob : ijob {     private myservices myservices { get; set; }     public hellojob(myservices myservices)     {         myservices = myservices;     }     public void execute(ijobexecutioncontext context)     {         var response = myservices.any(new servicemodel.hello         {             name = "coderevver"         });         response.printdump();     } } 

the above works fine. if in myservices class, removed function, , comment execute inner code.

public class myservices : service {  } 

the quartz.net error:

[quartz.core.errorlogger】 error occurred instantiating job executed. job= 'jobgroup1.getuserjob111' problem instantiating type 'servicestackwithquartz.hellojob' 

why class must have public object any(hello request) function ?

thanks using package – had no idea other people find useful.

so if understand correctly, in situation have:

public class myservices : service { } 

and you’re trying resolve service via constructor injection, doing a:

container.resolve<myservices>(); 

this fail because of way servicestack funq ioc works. can’t resolve servicestack service has nothing in (you'd never want either) – has @ least have 1 service implementation, doesn’t matter implementation is.

also, if want improve servicestack.funq.quartz, feel free contribute code base.

edit: it's worth mentioning can inject "non-service" class logic in if want. can resolve other classes aren't based off of servicestack.service if there's nothing in them.

edit 2: responding "service wont dispose" problem. same across servicestack , has nothing quartz job. if call a:

container.resolve<myservices>().any(new new servicemodel.hello { }); 

from apphost example, service wont dispose itself. if want dispose can wrap in using statement. e.g.

using (var service = myservices) {     var response = myservices.any(new servicemodel.hello { }); } 

the using ensure service disposed afterwards.

alternatively can add interface "idispose" on quartz job , implement dispose() method a:

myservices.dispose();   

this called after job has executed.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -