Last post Feb 16, 2006 10:39 AM by lilryno
Apr 15, 2005 09:17 PM|oliverd|LINK
I currently trying to write a schedule task which add / update users in DNN 3.0.13 using informtion from a ads.
My code looks like this:
As New UserInfo
' pulling out information from the ads and fill the UserInfo Object
When I use this code in a custom module, it works fine. For one user or up to several thounsand users. But when I try the same code in a scheduler task I get the following error:
Object reference not set to an instance of an object.
Message: System.NullReferenceException: Object reference not set to an instance of an object. at DotNetNuke.Common.Globals.SetApplicationName(Int32 PortalID) in C:\Inetpub\DotNetNuke\components\Shared\Globals.vb:line 278 at DotNetNuke.Entities.Users.UserController.AddUser(UserInfo
objUser, Boolean AddToMembershipProvider) in C:\Inetpub\DotNetNuke\components\Users\UserController.vb:line 540
I found out that the error seems to occurred in the function
HttpContext.Current.Items("ApplicationName") = GetApplicationName(PortalID)
in the DotNetNuke.Common.Globals Class
I have tested the code several times and as a module it is working fine but not in as a schedule task.
Can somebody help me?
Apr 15, 2005 09:57 PM|J7Mitch|LINK
You can't run it as a scheduled task because there isn't an HttpContext on the scheduler thread.
This may not be possible without actually doing it inside the main app because I think that is the only way to set the application for MemberRole.
I'll take a closer look and let you know, but another option is to put it into a webservice that runs in the same context as DotNetNuke, then have the code in the scheduler call the webservice.
Apr 16, 2005 01:22 AM|smehrotra75|LINK
I had to do something similar with my scheduled reports application (www.acuitigrids.com) since it can send out reports on a scheduled basis for specific users. There was something I did to fool the system to think
there was an HttpContext - let me dig it up and I'll shoot it off tomorrow...
Apr 16, 2005 11:56 PM|cpmoyer|LINK
Apr 17, 2005 04:37 AM|rodneyjoyce|LINK
Jun 29, 2005 12:47 PM|xzg3|LINK
Feb 16, 2006 10:39 AM|lilryno|LINK
Anybody find a way to populate a UserInfo object from within a Scheduler DoWork() method?