microsoft.public.windows.backgroundtransfer
[Top] [All Lists]

Re: BG_JOB_STATE_ERROR - AutoUpdater

Subject: Re: BG_JOB_STATE_ERROR - AutoUpdater
From: "Narayana Mahankali [MSFT]"
Date: Sat, 30 Jul 2005 00:51:56 -0700
Newsgroups: microsoft.public.windows.backgroundtransfer
What is the exact error code you are getting when the job goes into error 
state. There is nothing wrong with your code except that it might better to 
print the error code and description in case of error.Look at 
http://msdn.microsoft.com/library/en-us/bits/bits/ibackgroundcopyjob_geterror.asp
 
and 
                                msdn.microsoft.com/library/en-us/bits/bits/ibackgroundcopyerror.asp">http://msdn.microsoft.com/library/en-us/bits/bits/ibackgroundcopyerror.asp

I might be able to tell you what is wrong if you can get the exact error 
code. alternatively you can also get the bitsadmin.exe tool and run the 
following command from a command prompt:

bitsadmin /list /allusers /verbose > jobs.txt

and send me the jobs.txt file.

bitsadmin.exe can be downloaded from 
                                www.microsoft.com/downloads/details.aspx?amp;displaylang=en&familyid=49AE8576-9BB9-4126-9761-BA8011FABF38&displaylang=en">http://www.microsoft.com/downloads/details.aspx?amp;displaylang=en&familyid=49AE8576-9BB9-4126-9761-BA8011FABF38&displaylang=en


-- 
Narayana Mahankali
Microsoft, BITS

This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
                                www.microsoft.com/info/cpyright.htm">http://www.microsoft.com/info/cpyright.htm


"Anand" <Anand@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message 
news:4FED6196-E98F-4047-81C3-2C20801D53E9@xxxxxxxxxxxxxxxx
> Hi,
>
> I downloaded the sample autoupdater application from
>                                 msdn.microsoft.com/msdnmag/issues/03/02/BITS/default.aspx">http://msdn.microsoft.com/msdnmag/issues/03/02/BITS/default.aspx
>
> I am running WINDOWS XP SP1 with BITS service successfully running under
> local system account.
>
> When I run this application, it throws me BG_JOB_STATE_ERROR when I check
> the state of the job. the statement "               job.GetState(out 
> state);"
> returns BG_JOB_STATE_ERROR ALWAYS. I am not sure if job is getting added 
> or
> not.
>
> I have kept the files under                                 localhost/updates">http://localhost/updates with ONLY anonymous
> access on.
>
> Can somebody help me out.
>
> Here is the code snippit
>
>
>   // Do the file download and polling logic
>   static void HandleBits(Object o){
>      IBackgroundCopyManager bcm = null;
>      IBackgroundCopyJob job=null;
>      try{
>         // Create BITS object
>         bcm = (IBackgroundCopyManager)new BackgroundCopyManager();
>         Guid jobID=Guid.Empty;
>         if(xml.BitsJob != Guid.Empty){ // Do we already have a job in 
> place?
>            jobID = xml.BitsJob;
>            BG_JOB_STATE state;
>            try{
>               bcm.GetJob(ref jobID, out job); // Get the BITS job object
>               job.GetState(out state);        // check its state
>               switch(state){
>               case BG_JOB_STATE.BG_JOB_STATE_ERROR: // If it is an error,
> re-poll
>                  job.Complete();
>                  xml.BitsJob = Guid.Empty;
>                  Marshal.ReleaseComObject(job);
>                  job = null;
>                  break;
>               case BG_JOB_STATE.BG_JOB_STATE_TRANSFERRED: // If we got the
> job
>                  job.Complete();                          // then complete 
> it
>                  xml.BitsJob = Guid.Empty;
>                  return;
>               default:
>                  return;
>               }
>            }catch(COMException e){
>               if(e.ErrorCode == unchecked((Int32)0x80200001)){ // Job
> doesn't exist
>                  xml.BitsJob = Guid.Empty;
>               }else
>                  throw; // Some other error we didn't expect
>            }catch(UnauthorizedAccessException){
>               return; // We don't have access to the current job... no 
> biggie
>            }
>         }
>
>         // Create a bits job to download the next expected update
>         bcm.CreateJob("Application Update",
>            BG_JOB_TYPE.BG_JOB_TYPE_DOWNLOAD, out jobID, out job);
>         job.SetDescription("Updating application at "+baseDir);
>         String resource;
>         if(xml.PatchUrl[xml.PatchUrl.Length-1] == '/'){
>            resource = xml.PatchUrl+patchName;
>         }else{
>            resource =
>               String.Format("{0}/{1}", xml.PatchUrl, patchName);
>         }
>         // Add the file to the job
>         job.AddFile(resource, baseDir+patchName);
>         job.Resume(); // start the job in action
>         xml.BitsJob = jobID; // save the Job Guid
>      }finally{
>         // cleanup
>         if(job != null)
>            Marshal.ReleaseComObject(job);
>         if(bcm != null)
>            Marshal.ReleaseComObject(bcm);
>      }
>   }
> 



<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy