Scheduled job in community 2.4

Vote:
 
I' currently trying to execute code from the Community framework 2.4 on a scheduled job. But each time I run it I get an license exception due to the following.

ClubHandler handler = new ClubHandler()
However, the constructor will execute this
LicenseProvider.Validate(typeof(ClubHandler));
and this one will later try to read the httpcontext which isn't set since the scheduled job is running automaticly and not manually.

So, my question is, how can I run my code? Can I validate the license in some way from my scheduled job?

Error message from the log:
2008-11-13 00:00:48,279\t(null)\t3.1.2 Failed to execute job 296e01dc-b5cf-4e6b-bfd5-2291826a2073
System.NullReferenceException: Object reference not set to an instance of an object.
at StarSuite.Core.Licensing.LicenseProvider.get_IsTrustedMode()
at StarSuite.Core.Licensing.LicenseProvider.Validate(Type licensedType)
at StarCommunity.Modules.Club.ClubHandler..ctor()
#25995
Nov 17, 2008 8:01
Vote:
 

A solution to this problem could be to fake a httpcontext. Here is a quick link from googling on the subject:

http://dotnetbutchering.blogspot.com/2008/08/net-how-to-simulate-httpcontext-cookies.html

#26042
Nov 18, 2008 14:28
Vote:
 
Thanks Nicklas, that did the trick. I just had to create a new httpcontext before the new clubhandler call ant it worked.
#26046
Nov 18, 2008 15:55
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.