<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="/rss.xsl"?><rss version="2.0"><channel><title>SharpBITS.NET</title><link>http://sharpbits.codeplex.com/project/feeds/rss</link><description>SharpBITS.NET is a .NET wrapper of the BITS API and a little Windows UI application for easier access to BITS up- and downloads.    It&amp;#39;s developed in C&amp;#35; &amp;#40;obviously&amp;#41;, but the base wrapper can be used from any .NET application.</description><item><title>Reopened Issue: Compatibility issues with x64 systems [7046]</title><link>http://sharpbits.codeplex.com/workitem/7046</link><description>Utils.cs GetBitsVersion&amp;#40;&amp;#41; method fails on x64 systems, but as responses show there might be several more x64 traps around in the code. Solution is to force the system to run in 32bit mode. In Visual Studio set  Project &amp;#43; Properties, Build tab, Platform Target &amp;#61; x86.&lt;br /&gt;More details on the issue is on StackOverflow&amp;#58;&lt;br /&gt;&amp;#160;&lt;br /&gt;http&amp;#58;&amp;#47;&amp;#47;stackoverflow.com&amp;#47;questions&amp;#47;2283550&amp;#47;retrieving-dll-version-info-via-win32-verqueryvalue-crashes-under-win7-x64&lt;br /&gt;</description><author>xidar</author><pubDate>Fri, 14 Jun 2013 07:15:51 GMT</pubDate><guid isPermaLink="false">Reopened Issue: Compatibility issues with x64 systems [7046] 20130614071551A</guid></item><item><title>Reopened Task: Please target as low a version of .NET as possible [12433]</title><link>http://sharpbits.codeplex.com/workitem/12433</link><description>At changesets 65477 and 65478, the projects were upgraded to Visual Studio 2010 and the versions were bumped from 2.0 and 3.5 to 4.0.&lt;br /&gt;&amp;#160;&lt;br /&gt;The problem with that is a project that must target, say, .NET version 3.5 &amp;#40;for legacy reasons&amp;#41; can not reference SharpBITS.Base.dll.  It is possible to develop and compile with Visual Studio 2010 and the newest C&amp;#35; compiler and related tools, but still target an older framework version.&lt;br /&gt;&amp;#160;&lt;br /&gt;This can be as simple as changing the following line in SharpBITS.Base.csproj &amp;#40;I picked version 3.5 to be consistent with my example&amp;#41;&amp;#58;&lt;br /&gt;&amp;#64;&amp;#64; -22,7 &amp;#43;22,7 &amp;#64;&amp;#64;&lt;br /&gt;     &amp;#60;UpgradeBackupLocation&amp;#62;&lt;br /&gt;     &amp;#60;&amp;#47;UpgradeBackupLocation&amp;#62;&lt;br /&gt;     &amp;#60;OldToolsVersion&amp;#62;3.5&amp;#60;&amp;#47;OldToolsVersion&amp;#62;&lt;br /&gt;-    &amp;#60;TargetFrameworkVersion&amp;#62;v4.0&amp;#60;&amp;#47;TargetFrameworkVersion&amp;#62;&lt;br /&gt;&amp;#43;    &amp;#60;TargetFrameworkVersion&amp;#62;v3.5&amp;#60;&amp;#47;TargetFrameworkVersion&amp;#62;&lt;br /&gt;     &amp;#60;PublishUrl&amp;#62;publish&amp;#92;&amp;#60;&amp;#47;PublishUrl&amp;#62;&lt;br /&gt;     &amp;#60;Install&amp;#62;true&amp;#60;&amp;#47;Install&amp;#62;&lt;br /&gt;     &amp;#60;InstallFrom&amp;#62;Disk&amp;#60;&amp;#47;InstallFrom&amp;#62;&lt;br /&gt;&amp;#160;&lt;br /&gt;...or can be done from within Visual Studio itself by a right-click on the project &amp;#62; Properties &amp;#62; Application &amp;#62; Target framework.&lt;br /&gt;&amp;#160;&lt;br /&gt;Alternately, you could do what James does with his Newtonsoft.Json NuGet package and bundle assemblies targeting multiple frameworks at once, but that&amp;#39;s more work. &amp;#58;&amp;#41;&lt;br /&gt;&amp;#160;&lt;br /&gt;Thanks&amp;#33;&lt;br /&gt;- Oli&lt;br /&gt;</description><author>OliIsCool</author><pubDate>Fri, 14 Jun 2013 07:15:51 GMT</pubDate><guid isPermaLink="false">Reopened Task: Please target as low a version of .NET as possible [12433] 20130614071551A</guid></item><item><title>Closed Issue: Compatibility issues with x64 systems [7046]</title><link>http://sharpbits.codeplex.com/workitem/7046</link><description>Utils.cs GetBitsVersion&amp;#40;&amp;#41; method fails on x64 systems, but as responses show there might be several more x64 traps around in the code. Solution is to force the system to run in 32bit mode. In Visual Studio set  Project &amp;#43; Properties, Build tab, Platform Target &amp;#61; x86.&lt;br /&gt;More details on the issue is on StackOverflow&amp;#58;&lt;br /&gt;&amp;#160;&lt;br /&gt;http&amp;#58;&amp;#47;&amp;#47;stackoverflow.com&amp;#47;questions&amp;#47;2283550&amp;#47;retrieving-dll-version-info-via-win32-verqueryvalue-crashes-under-win7-x64&lt;br /&gt;</description><author>xidar</author><pubDate>Thu, 16 May 2013 09:59:00 GMT</pubDate><guid isPermaLink="false">Closed Issue: Compatibility issues with x64 systems [7046] 20130516095900A</guid></item><item><title>Closed Task: Please target as low a version of .NET as possible [12433]</title><link>http://sharpbits.codeplex.com/workitem/12433</link><description>At changesets 65477 and 65478, the projects were upgraded to Visual Studio 2010 and the versions were bumped from 2.0 and 3.5 to 4.0.&lt;br /&gt;&amp;#160;&lt;br /&gt;The problem with that is a project that must target, say, .NET version 3.5 &amp;#40;for legacy reasons&amp;#41; can not reference SharpBITS.Base.dll.  It is possible to develop and compile with Visual Studio 2010 and the newest C&amp;#35; compiler and related tools, but still target an older framework version.&lt;br /&gt;&amp;#160;&lt;br /&gt;This can be as simple as changing the following line in SharpBITS.Base.csproj &amp;#40;I picked version 3.5 to be consistent with my example&amp;#41;&amp;#58;&lt;br /&gt;&amp;#64;&amp;#64; -22,7 &amp;#43;22,7 &amp;#64;&amp;#64;&lt;br /&gt;     &amp;#60;UpgradeBackupLocation&amp;#62;&lt;br /&gt;     &amp;#60;&amp;#47;UpgradeBackupLocation&amp;#62;&lt;br /&gt;     &amp;#60;OldToolsVersion&amp;#62;3.5&amp;#60;&amp;#47;OldToolsVersion&amp;#62;&lt;br /&gt;-    &amp;#60;TargetFrameworkVersion&amp;#62;v4.0&amp;#60;&amp;#47;TargetFrameworkVersion&amp;#62;&lt;br /&gt;&amp;#43;    &amp;#60;TargetFrameworkVersion&amp;#62;v3.5&amp;#60;&amp;#47;TargetFrameworkVersion&amp;#62;&lt;br /&gt;     &amp;#60;PublishUrl&amp;#62;publish&amp;#92;&amp;#60;&amp;#47;PublishUrl&amp;#62;&lt;br /&gt;     &amp;#60;Install&amp;#62;true&amp;#60;&amp;#47;Install&amp;#62;&lt;br /&gt;     &amp;#60;InstallFrom&amp;#62;Disk&amp;#60;&amp;#47;InstallFrom&amp;#62;&lt;br /&gt;&amp;#160;&lt;br /&gt;...or can be done from within Visual Studio itself by a right-click on the project &amp;#62; Properties &amp;#62; Application &amp;#62; Target framework.&lt;br /&gt;&amp;#160;&lt;br /&gt;Alternately, you could do what James does with his Newtonsoft.Json NuGet package and bundle assemblies targeting multiple frameworks at once, but that&amp;#39;s more work. &amp;#58;&amp;#41;&lt;br /&gt;&amp;#160;&lt;br /&gt;Thanks&amp;#33;&lt;br /&gt;- Oli&lt;br /&gt;</description><author>OliIsCool</author><pubDate>Thu, 16 May 2013 09:58:59 GMT</pubDate><guid isPermaLink="false">Closed Task: Please target as low a version of .NET as possible [12433] 20130516095859A</guid></item><item><title>New Post:  BITS Upload : How to Retrieve the Job Status Using GUID or JobName</title><link>http://sharpbits.codeplex.com/discussions/442374</link><description>&lt;div style="line-height: normal;"&gt;Really, Thank you  Giovanni. Thanks alot &lt;br /&gt;
&lt;/div&gt;</description><author>SreeRama87</author><pubDate>Sat, 04 May 2013 05:32:37 GMT</pubDate><guid isPermaLink="false">New Post:  BITS Upload : How to Retrieve the Job Status Using GUID or JobName 20130504053237A</guid></item><item><title>New Post:  BITS Upload : How to Retrieve the Job Status Using GUID or JobName</title><link>http://sharpbits.codeplex.com/discussions/442374</link><description>&lt;div style="line-height: normal;"&gt;Hi&lt;br /&gt;
&lt;br /&gt;
if you want to know the job status using the job id you can ask it to the BitsManager object like in the snippet below&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;BitsManager manager = new BitsManager();
BitsJob job = manager.CreateJob(&amp;quot;Downloader&amp;quot;, JobType.Download);
job.AddFile(fromFile, toURL);
// get job id
Guid jobId = job.JobId;

// retrieve the job from manager
BitsJob currentJob  = manager.Jobs[jobId];
JobState jobState = currentJob.State;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;</description><author>giovanni_enrico</author><pubDate>Fri, 03 May 2013 07:59:49 GMT</pubDate><guid isPermaLink="false">New Post:  BITS Upload : How to Retrieve the Job Status Using GUID or JobName 20130503075949A</guid></item><item><title>New Post:  BITS Upload : How to Retrieve the Job Status Using GUID or JobName</title><link>http://sharpbits.codeplex.com/discussions/442374</link><description>&lt;div style="line-height: normal;"&gt;Dear Team,&lt;br /&gt;
&lt;br /&gt;
I'm successfully uploading   file onto server using  BITS  , while sending each file onto server i'm able to check for the Job Status and perform my actions accordingly.&lt;br /&gt;
&lt;br /&gt;
Please let me know how to get  Job Status using GUID/Job Name? . I have to check  using GUID because i'm storing it for polling purpose, so that I can check the Status later and Handle events accordingly?&lt;br /&gt;
&lt;br /&gt;
Here is my code.&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;try
        {
            string[] files = null;
            BitsJobs MultipleJobs = null;


            string Path1 = @&amp;quot;C:\Upload1&amp;quot;;
            if (Directory.Exists(Path1))
            {
                files = Directory.GetFiles(Path1);
            }


            if (files.Count() &amp;gt; 1)
            {


            }


            int x = files.Count();


            String[,] myArray3 = new string[x, x];

            Collection&amp;lt;BitsFileInfo&amp;gt; obj1 = new Collection&amp;lt;BitsFileInfo&amp;gt;();
            int i = 0;
            for (i = 0; i &amp;lt;= files.GetUpperBound(0)  i++)
            {

                DateTime DATE = System.DateTime.Now;

                JobType jtx = JobType.Upload;
                BitsManager BitsManager1 = new BitsManager();
                BitsJob bjobs;

                string JobName = DATE.ToString(&amp;quot;ddMMyyyyhhmmssfff&amp;quot;);

                bjobs = BitsManager1.CreateJob(JobName,  jtx);




                string Source = @&amp;quot;C:\RUN&amp;quot;;
                string Destination = @&amp;quot;http:\\RUN201:12345/&amp;quot;;

                BitsCredentials cred = new BitsCredentials();
                cred.AuthenticationScheme = AuthenticationScheme.Basic;
                cred.AuthenticationTarget = AuthenticationTarget.Server;
                cred.UserName = @&amp;quot;dc\admin&amp;quot;;
                cred.Password = @&amp;quot;Hello@123#&amp;quot;;
                bjobs.AddCredentials(cred);


                string name = files[i].ToString();
                string FileName = Path.GetFileName(name);

                string RemoteURL = Destination + @&amp;quot;/&amp;quot; + FileName;

                bjobs.AddFile(RemoteURL,  name);
                bjobs.Resume();

                JobState ds = 0;
                ds = bjobs.State;
                Guid ID = bjobs.JobId;
                // MultipleJobs.Add(ID, bjobs);
                if (!File.Exists(@&amp;quot;D:\log.txt&amp;quot;))
                {

                    File.CreateText(@&amp;quot;D:'log.txt&amp;quot;);
                }


                using (StreamWriter w = File.AppendText(@&amp;quot;D:\log.txt&amp;quot;))
                {
                    Log(ID + &amp;quot;,&amp;quot; + JobName, w);
                }
            }





            JobState bs = 0;
            //bs = bjobs.State;
            bool jobcomplete = false;
            // string Error = bjobs.Error; 

            //bjobs.NoProgressTimeout = 60;
            do
            {
                System.Threading.Thread.Sleep(19000);

                //  bs = bjobs.State;
                //Guid ID = bjobs.JobId;

                //MulipleJobs.Add(ID, bjobs);



                if (bs == JobState.Transferred)
                    jobcomplete = true;
                if (bs == JobState.Acknowledged)
                    jobcomplete = true;
                if (bs == JobState.Error)
                    jobcomplete = true;
                if (bs == JobState.Canceled)
                    jobcomplete = true;
            } while (!jobcomplete);



            int err = 0;
            string errdesc = null;

            BitsError ie = null;




            int errvalue;
            string contexterr = null;
            string errortext = null;


            if (bs == JobState.Error)
            {
                try
                {

                    //bs.GetError(out ie);
                    err = ie.ErrorCode;
                    errdesc = ie.Description;
                    //          ie.GetError(out cerr, out err );
                    //          errvalue = err;
                    //        //  contexterr = cerr;
                    //          ie.GetErrorDescription(
                    //    (uint)System.Threading.Thread.CurrentThread.CurrentCulture.LCID,
                    //    out errdesc);
                    //          if (errdesc != null)
                    //              errortext = errdesc;
                }
                catch (Exception ex)
                {
                    //          Debug.WriteLine(&amp;quot;Problem getting error description: &amp;quot; +
                    //                     ex.Message);
                    //          Debug.WriteLine(ex.StackTrace);
                }
                finally
                {
                    //   bjobs.Suspend();
                }
            }
            //  else
            //      Job.Complete();
            // 
        }
        catch (Exception Es)&lt;/code&gt;&lt;/pre&gt;

{&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;        }
    }






    public static void Log(string logMessage, TextWriter Writer)
    {

        Writer.WriteLine(&amp;quot; {0} {1} :{2}&amp;quot;,DateTime.Now.ToLongTimeString(), DateTime.Now.ToLongDateString(), logMessage);
    }





}
&lt;/code&gt;&lt;/pre&gt;

Please help me in solving this issue&lt;br /&gt;
&lt;/div&gt;</description><author>SreeRama87</author><pubDate>Thu, 02 May 2013 17:07:59 GMT</pubDate><guid isPermaLink="false">New Post:  BITS Upload : How to Retrieve the Job Status Using GUID or JobName 20130502050759P</guid></item><item><title>New Post: SharpBits - Error: The requested URL does not exist on the server</title><link>http://sharpbits.codeplex.com/discussions/439226</link><description>&lt;div style="line-height: normal;"&gt;Hi&lt;br /&gt;
&lt;br /&gt;
I am using your sample code for testing so I can create my own utility to transfer the file manually from our data server. Server is credentials protected and I am using HTTPS in the url.&lt;br /&gt;
&lt;br /&gt;
When I run the code I get the errors:&lt;br /&gt;
1) Error description: The requested URL does not exist on the server&lt;br /&gt;
2) Error context: Remote file&lt;br /&gt;
Error context description: The error occurred while the remote file was being processed.&lt;br /&gt;
3) Error protocol: Https&lt;br /&gt;
&lt;br /&gt;
Could you please help me understanding those error and what would be the root cause. I can access the Https url in the browser with the same credentials I've hard coded into the app.&lt;br /&gt;
&lt;br /&gt;
Thanks&lt;br /&gt;
&lt;/div&gt;</description><author>shoaibsuleman</author><pubDate>Fri, 05 Apr 2013 11:46:08 GMT</pubDate><guid isPermaLink="false">New Post: SharpBits - Error: The requested URL does not exist on the server 20130405114608A</guid></item><item><title>Commented Issue: The RPC Server is Unavailable [12848]</title><link>http://sharpbits.codeplex.com/workitem/12848</link><description>Win Server 2008 R2 64bit &amp;#43; implemented as Windows service &amp;#40;already updated to latest SharpBITS library&amp;#41;.&lt;br /&gt;&lt;br /&gt;This error occurs randomly - once in couple days. It makes all other calls to BITS manager object to fail &amp;#61;&amp;#62; and windows service stops due BITS error event started. I did one workaround - wrapped call to the list Queue method with &amp;#34;try .. catch&amp;#34; and recreate BITS manager object &amp;#34;on error&amp;#34;. But this hack-style solution only little bit improved stability - now service suddenly stops working without any error about once in a week.  &amp;#58;&amp;#40; &lt;br /&gt;&lt;br /&gt;&amp;#40;Same code worked perfectly on Win Server 2003.&amp;#41;&lt;br /&gt;Comments: ** Comment from web user: jmalinovskis ** &lt;p&gt;Results from Debug Diagnostics Tool v1.2:&lt;/p&gt;&lt;p&gt;In DIBIST~3.DMP the assembly instruction at KERNELBASE!RaiseException+39 in C:\Windows\System32\KERNELBASE.dll from Microsoft Corporation has caused an unknown exception (0x800706be) on thread 9&lt;br&gt;Thread 9 - System ID 4288&lt;br&gt;Entry point   clr!Thread::intermediateThreadProc &lt;br&gt;Create time   06.03.2013 11:49:47 &lt;br&gt;Time spent in user mode   0 Days 0:0:0.125 &lt;br&gt;Time spent in kernel mode   0 Days 0:0:0.62 &lt;br&gt;.NET Call Stack&lt;br&gt;Function &lt;br&gt;SharpBits.Base.IBackgroundCopyJob.SetNotifyInterface(System.Object)&lt;/p&gt;</description><author>jmalinovskis</author><pubDate>Wed, 06 Mar 2013 11:39:59 GMT</pubDate><guid isPermaLink="false">Commented Issue: The RPC Server is Unavailable [12848] 20130306113959A</guid></item><item><title>Created Issue: The RPC Server is Unavailable [12848]</title><link>http://sharpbits.codeplex.com/workitem/12848</link><description>Win Server 2008 R2 64bit &amp;#43; implemented as Windows service &amp;#40;already updated to latest SharpBITS library&amp;#41;.&lt;br /&gt;&lt;br /&gt;This error occurs randomly - once in couple days. It makes all other calls to BITS manager object to fail &amp;#61;&amp;#62; and windows service stops due BITS error event started. I did one workaround - wrapped call to the list Queue method with &amp;#34;try .. catch&amp;#34; and recreate BITS manager object &amp;#34;on error&amp;#34;. But this hack-style solution only little bit improved stability - now service suddenly stops working without any error about once in a week.  &amp;#58;&amp;#40; &lt;br /&gt;&lt;br /&gt;&amp;#40;Same code worked perfectly on Win Server 2003.&amp;#41;&lt;br /&gt;</description><author>jmalinovskis</author><pubDate>Mon, 04 Mar 2013 17:14:24 GMT</pubDate><guid isPermaLink="false">Created Issue: The RPC Server is Unavailable [12848] 20130304051424P</guid></item><item><title>Reviewed: SharpBITS 2.0 WinApp (févr. 21, 2013)</title><link>http://sharpbits.codeplex.com/releases/view/65508#ReviewBy-lfrancfort</link><description>Rated 4 Stars &amp;#40;out of 5&amp;#41; - Very easy to use, but the lack of documentation is a waste of time</description><author>lfrancfort</author><pubDate>Thu, 21 Feb 2013 15:04:37 GMT</pubDate><guid isPermaLink="false">Reviewed: SharpBITS 2.0 WinApp (févr. 21, 2013) 20130221030437P</guid></item><item><title>New Post: EnumJobs whit AllUsers give E_ACCESSDENIED error</title><link>http://sharpbits.codeplex.com/discussions/280737</link><description>&lt;div style="line-height: normal;"&gt;&lt;p&gt;Looks like issue in BITS 4.0 when trying to pass allusers for enum for this job.  I think Microsoft changed the security protocol from reading their documentation.  A virtual login doesn't give you the access you need to view another users BITS jobs from my basic understanding.  &lt;/p&gt;
&lt;/div&gt;</description><author>bcanon</author><pubDate>Wed, 06 Feb 2013 14:49:12 GMT</pubDate><guid isPermaLink="false">New Post: EnumJobs whit AllUsers give E_ACCESSDENIED error 20130206024912P</guid></item><item><title>New Post: IBackgroundCopyJobHttpOptions</title><link>http://sharpbits.codeplex.com/discussions/52476</link><description>&lt;div style="line-height: normal;"&gt;
&lt;p&gt;In my opinion it's a good workaround, but I'm still searching for a solution without additional DLL. If anybody finds a solution using only managed code, I would be very happy, if it posted here.&lt;/p&gt;
&lt;/div&gt;</description><author>schmid03</author><pubDate>Thu, 24 Jan 2013 06:47:13 GMT</pubDate><guid isPermaLink="false">New Post: IBackgroundCopyJobHttpOptions 20130124064713A</guid></item><item><title>New Post: IBackgroundCopyJobHttpOptions</title><link>http://sharpbits.codeplex.com/discussions/52476</link><description>&lt;div style="line-height: normal;"&gt;
&lt;p&gt;Excellent alternative. Thank you much for posting that code.&lt;/p&gt;
&lt;/div&gt;</description><author>mldisibio</author><pubDate>Wed, 23 Jan 2013 16:07:45 GMT</pubDate><guid isPermaLink="false">New Post: IBackgroundCopyJobHttpOptions 20130123040745P</guid></item><item><title>New Post: IBackgroundCopyJobHttpOptions</title><link>http://sharpbits.codeplex.com/discussions/52476</link><description>&lt;div style="line-height: normal;"&gt;
&lt;p&gt;For setting the custom headers i've implemented a separate c&amp;#43;&amp;#43; dl with unmanaged code:&lt;/p&gt;
&lt;p&gt;Header file&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div style="color:black; background-color:white"&gt;
&lt;pre&gt;&lt;span style="color:green"&gt;// THIS CODE AND INFORMATION IS PROVIDED &amp;quot;AS IS&amp;quot; WITHOUT WARRANTY OF&lt;/span&gt;
&lt;span style="color:green"&gt;// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO&lt;/span&gt;
&lt;span style="color:green"&gt;// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A&lt;/span&gt;
&lt;span style="color:green"&gt;// PARTICULAR PURPOSE.&lt;/span&gt;
&lt;span style="color:green"&gt;//&lt;/span&gt;
&lt;span style="color:green"&gt;// Copyright (c) Microsoft Corporation. All rights reserved.&lt;/span&gt;
#pragma once

#undef __REQUIRED_RPCNDR_H_VERSION__
#ifndef _DLL_TEST
#define _DLL_TEST
#include &amp;lt;bits3_0.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;tchar.h&amp;gt;
#include &amp;lt;lm.h&amp;gt;
#include &amp;lt;iostream&amp;gt;

#&lt;span style="color:blue"&gt;if&lt;/span&gt; defined DLL_EXPORT
#define DECLDIR __declspec(&lt;span style="color:blue"&gt;dllexport&lt;/span&gt;)
#&lt;span style="color:blue"&gt;else&lt;/span&gt;
#define DECLDIR __declspec(&lt;span style="color:blue"&gt;dllimport&lt;/span&gt;)
#endif

&lt;span style="color:blue"&gt;using&lt;/span&gt; &lt;span style="color:blue"&gt;namespace&lt;/span&gt; std;

&lt;span style="color:blue"&gt;extern&lt;/span&gt; &lt;span style="color:#a31515"&gt;&amp;quot;C&amp;quot;&lt;/span&gt;
{
	 DECLDIR &lt;span style="color:blue"&gt;bool&lt;/span&gt; setCustomHeaders(GUID guidJob, LPCWSTR pwszHeader);
}

#endif
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Implementation file:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div style="color:black; background-color:white"&gt;
&lt;pre&gt;&lt;span style="color:green"&gt;// THIS CODE AND INFORMATION IS PROVIDED &amp;quot;AS IS&amp;quot; WITHOUT WARRANTY OF&lt;/span&gt;
&lt;span style="color:green"&gt;// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO&lt;/span&gt;
&lt;span style="color:green"&gt;// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A&lt;/span&gt;
&lt;span style="color:green"&gt;// PARTICULAR PURPOSE.&lt;/span&gt;
&lt;span style="color:green"&gt;//&lt;/span&gt;
&lt;span style="color:green"&gt;// Copyright (c) Microsoft Corporation. All rights reserved.&lt;/span&gt;
#define DLL_EXPORT
#include &lt;span style="color:#a31515"&gt;&amp;quot;BITSHELPER.h&amp;quot;&lt;/span&gt;

&lt;span style="color:blue"&gt;extern&lt;/span&gt; &lt;span style="color:#a31515"&gt;&amp;quot;C&amp;quot;&lt;/span&gt;
{
	DECLDIR &lt;span style="color:blue"&gt;bool&lt;/span&gt; setCustomHeaders(GUID guidJob, LPCWSTR pwszHeader)
	{	
		HRESULT hr;
		IBackgroundCopyManager *pQueueMgr;
		IBackgroundCopyJob* pJob = NULL;
		IBackgroundCopyJobHttpOptions* pHttp = NULL;
		&lt;span style="color:green"&gt;// LPCWSTR pwszHeader = L&amp;quot;Authorization: Basic YWxleDphbGV4\r\n&amp;quot;;&lt;/span&gt;

		&lt;span style="color:green"&gt;// Connect to BITS&lt;/span&gt;
		hr = CoCreateInstance(__uuidof(BackgroundCopyManager), NULL, CLSCTX_LOCAL_SERVER, __uuidof(IBackgroundCopyManager), (&lt;span style="color:blue"&gt;void&lt;/span&gt; **)&amp;amp;pQueueMgr);

		&lt;span style="color:blue"&gt;if&lt;/span&gt; (FAILED(hr)) &lt;span style="color:green"&gt;// Failed to connect&lt;/span&gt;
		{	
			wprintf(L&lt;span style="color:#a31515"&gt;&amp;quot;Failed to connect to BITS.Error: 0x%x\n&amp;quot;&lt;/span&gt;,hr);
			&lt;span style="color:blue"&gt;goto&lt;/span&gt; done;
		}

		&lt;span style="color:green"&gt;// Get Job&lt;/span&gt;
		wprintf(L&lt;span style="color:#a31515"&gt;&amp;quot;Get Job...\n&amp;quot;&lt;/span&gt;);
		hr = pQueueMgr-&amp;gt;GetJobW(guidJob, &amp;amp;pJob);

		&lt;span style="color:green"&gt;// Free resources&lt;/span&gt;
		pQueueMgr-&amp;gt;Release();

		&lt;span style="color:blue"&gt;if&lt;/span&gt;(FAILED(hr))
		{   
			wprintf(L&lt;span style="color:#a31515"&gt;&amp;quot;Get Job failed with error: %x\n&amp;quot;&lt;/span&gt;,hr);
    		&lt;span style="color:blue"&gt;goto&lt;/span&gt; done;
		}
    
		&lt;span style="color:green"&gt;// Get the IBackgroundCopyJobHttpOptions interface     &lt;/span&gt;
		hr = pJob-&amp;gt;QueryInterface(__uuidof(IBackgroundCopyJobHttpOptions), (&lt;span style="color:blue"&gt;void&lt;/span&gt; **)&amp;amp;pHttp);
	
		&lt;span style="color:blue"&gt;if&lt;/span&gt; (FAILED(hr))
		{
			wprintf(L&lt;span style="color:#a31515"&gt;&amp;quot;Unable to get IBackgroundCopyJobHttpOptions Interface\n&amp;quot;&lt;/span&gt;);
		}

		&lt;span style="color:green"&gt;// Set the custom header to given value&lt;/span&gt;
		hr = pHttp-&amp;gt;SetCustomHeaders(pwszHeader);

		&lt;span style="color:green"&gt;// Release resources&lt;/span&gt;
		pHttp-&amp;gt;Release();

		&lt;span style="color:blue"&gt;if&lt;/span&gt; (FAILED(hr))
		{
			&lt;span style="color:green"&gt;//SetCustomHeaders Failed&lt;/span&gt;
			wprintf(L&lt;span style="color:#a31515"&gt;&amp;quot;SetCustomHeaders failed with error %x\n&amp;quot;&lt;/span&gt;,hr);
		}
        &lt;span style="color:blue"&gt;return&lt;/span&gt; &lt;span style="color:blue"&gt;true&lt;/span&gt;;
	done:
	failed:
		&lt;span style="color:blue"&gt;return&lt;/span&gt; &lt;span style="color:blue"&gt;false&lt;/span&gt;;
	cancel:
		pJob-&amp;gt;Cancel();
		pJob-&amp;gt;Release();
		&lt;span style="color:blue"&gt;goto&lt;/span&gt; done;
	}
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;These sources are compiled to a native dll. This dll is then referenced from my managed code and I call the dll from my managed code like in this snippet:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div style="color:black; background-color:white"&gt;
&lt;pre&gt;[DllImport(&lt;span style="color:#a31515"&gt;&amp;quot;bitshttpheader.dll&amp;quot;&lt;/span&gt;, CallingConvention = CallingConvention.Cdecl)]
&lt;span style="color:blue"&gt;private&lt;/span&gt; &lt;span style="color:blue"&gt;static&lt;/span&gt; &lt;span style="color:blue"&gt;extern&lt;/span&gt; &lt;span style="color:blue"&gt;void&lt;/span&gt; setCustomHeaders(Guid guid, [MarshalAs(UnmanagedType.LPWStr)] string pwszHeader);

&lt;span style="color:green"&gt;// snipp some code here.......&lt;/span&gt;

            BitsManager manager = &lt;span style="color:blue"&gt;new&lt;/span&gt; BitsManager();
            manager.EnumJobs(JobOwner.CurrentUser);
            manager.OnJobTransferred &amp;#43;= &lt;span style="color:blue"&gt;new&lt;/span&gt; EventHandler&amp;lt;NotificationEventArgs&amp;gt;(manager_OnJobTransferred);
            manager.OnJobError &amp;#43;= &lt;span style="color:blue"&gt;new&lt;/span&gt; EventHandler&amp;lt;ErrorNotificationEventArgs&amp;gt;(manager_OnJobError);

            BitsJob newJob = manager.CreateJob(&lt;span style="color:#a31515"&gt;&amp;quot;TestJob&amp;quot;&lt;/span&gt;, JobType.UploadReply);
            newJob.AddFile(UploadDesitination &amp;#43; &lt;span style="color:#a31515"&gt;&amp;quot;x.txt&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515"&gt;&amp;quot;C:\\x.txt&amp;quot;&lt;/span&gt;);
            Guid guid = newJob.JobId;

            setCustomHeaders(guid, &lt;span style="color:#a31515"&gt;&amp;quot;MyHeader_2: Header Two Value\r\n&amp;quot;&lt;/span&gt;);
            newJob.Resume();

&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This code is just a working prove of concept for me and I'm still searching for a 'cleaner' solution.&lt;/p&gt;
&lt;/div&gt;</description><author>schmid03</author><pubDate>Wed, 23 Jan 2013 08:32:29 GMT</pubDate><guid isPermaLink="false">New Post: IBackgroundCopyJobHttpOptions 20130123083229A</guid></item><item><title>New Post: IBackgroundCopyJobHttpOptions</title><link>http://sharpbits.codeplex.com/discussions/52476</link><description>&lt;div style="line-height: normal;"&gt;
&lt;p&gt;So I put this code inside my BackgroundCopyJob implementation as the managed version of your snippet above:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div style="color:black; background-color:white"&gt;
&lt;pre&gt;&lt;span style="color:blue"&gt;public&lt;/span&gt; IBackgroundCopyJobHttpOptions HttpOptions
{
	&lt;span style="color:blue"&gt;get&lt;/span&gt;
	{
		Guid interfaceGuid = &lt;span style="color:blue"&gt;typeof&lt;/span&gt;(IBackgroundCopyJobHttpOptions).GUID;
		IntPtr jobPtr = Marshal.GetIUnknownForObject(&lt;span style="color:blue"&gt;this&lt;/span&gt;.interopJob);
		IntPtr httpOptionsPtr;
		Marshal.QueryInterface(jobPtr, &lt;span style="color:blue"&gt;ref&lt;/span&gt; interfaceGuid, &lt;span style="color:blue"&gt;out&lt;/span&gt; httpOptionsPtr);
		&lt;span style="color:blue"&gt;return&lt;/span&gt; Marshal.GetObjectForIUnknown(httpOptionsPtr) &lt;span style="color:blue"&gt;as&lt;/span&gt; IBackgroundCopyJobHttpOptions;
	}
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It comes back with a non-null object, and if I query, say, 'httpOptions.GetSecurityFlags(out secFlags)' I get a uint or ulong of zero. But I stil get the AccessViolation if I try to set them.&lt;/p&gt;
&lt;p&gt;Can you post an example of how you call your unmanaged code snippet from managed?&lt;/p&gt;
&lt;p&gt;Also, I am not an expert in COM Interop, but based on the other signature translations and what I have read about how an umanaged ulong is really only four bytes, I was thinking the interface definition you proposed ought to be&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div style="color:black; background-color:white"&gt;
&lt;pre&gt;&lt;span style="color:blue"&gt;void&lt;/span&gt; SetSecurityFlags([In] &lt;span style="color:blue"&gt;uint&lt;/span&gt; Flags);
&lt;span style="color:blue"&gt;void&lt;/span&gt; GetSecurityFlags(&lt;span style="color:blue"&gt;out&lt;/span&gt; &lt;span style="color:blue"&gt;uint&lt;/span&gt; Flags);
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;</description><author>mldisibio</author><pubDate>Tue, 22 Jan 2013 15:44:37 GMT</pubDate><guid isPermaLink="false">New Post: IBackgroundCopyJobHttpOptions 20130122034437P</guid></item><item><title>New Post: IBackgroundCopyJob4 not implemented in Windows 8? </title><link>http://sharpbits.codeplex.com/discussions/406884</link><description>&lt;div style="line-height: normal;"&gt;
&lt;p&gt;sounds like there is some need for improvement. I'll have those fixed incorporated in the source and publish an updated version.&lt;/p&gt;
&lt;/div&gt;</description><author>xidar</author><pubDate>Mon, 21 Jan 2013 16:30:00 GMT</pubDate><guid isPermaLink="false">New Post: IBackgroundCopyJob4 not implemented in Windows 8?  20130121043000P</guid></item><item><title>New Post: IBackgroundCopyJobHttpOptions</title><link>http://sharpbits.codeplex.com/discussions/52476</link><description>&lt;div style="line-height: normal;"&gt;
&lt;p&gt;As far as I know the cast is the same as&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div style="color:black; background-color:white"&gt;
&lt;pre&gt;  IBackgroundCopyJob* pJob = NULL;
  IBackgroundCopyJobHttpOptions* pHttpOptions = NULL;

  hr = pJob-&amp;gt;QueryInterface(__uuidof(IBackgroundCopyJobHttpOptions), (&lt;span style="color:blue"&gt;void&lt;/span&gt;**)&amp;pHttpOptions);
&lt;/pre&gt;
&lt;/div&gt;
I use this code snippet in an extra .dll which I call from my managed code and then it's possible to set the custom header in pHttpOptions without any problems.
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;/div&gt;</description><author>schmid03</author><pubDate>Mon, 21 Jan 2013 07:32:23 GMT</pubDate><guid isPermaLink="false">New Post: IBackgroundCopyJobHttpOptions 20130121073223A</guid></item><item><title>New Post: IBackgroundCopyJobHttpOptions</title><link>http://sharpbits.codeplex.com/discussions/52476</link><description>&lt;div style="line-height: normal;"&gt;
&lt;p&gt;http://msdn.microsoft.com/en-us/library/windows/desktop/aa964250(v=vs.85).aspx says to call the&amp;nbsp;IBackgroundCopyJob::QueryInterface method with the HttpOptions guid...but I do not see that method defined anywhere...&lt;/p&gt;
&lt;p&gt;I would suspect that casting a job to the IBackgroundCopyJobHttpOptions is not the correct way to get a handle to the options...but I don't have a solution yet either...&lt;/p&gt;
&lt;/div&gt;</description><author>mldisibio</author><pubDate>Fri, 18 Jan 2013 20:40:10 GMT</pubDate><guid isPermaLink="false">New Post: IBackgroundCopyJobHttpOptions 20130118084010P</guid></item><item><title>New Post: IBackgroundCopyJob4 not implemented in Windows 8? </title><link>http://sharpbits.codeplex.com/discussions/406884</link><description>&lt;div style="line-height: normal;"&gt;
&lt;p&gt;Just wanted to confirm that I had the same exact problem and fixed it by correcting the Guid.&lt;/p&gt;
&lt;p&gt;Also, schmid03 is correct that checking the qmgr.dll version does not work correctly on Windows Server 2008 R2 and possible other versions of Windows. In some cases, I believe the dll even has a different name. Based on some old code found in the msdn forums
 back in the days of version 1.5, I created the following way to check:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div style="color:black; background-color:white"&gt;
&lt;pre&gt;&lt;span style="color:blue"&gt;readonly&lt;/span&gt; BitsVersion _version = BITSWrapper.BitsVersion.Bits0_0;
&lt;span style="color:blue"&gt;try&lt;/span&gt;
{
	&lt;span style="color:blue"&gt;this&lt;/span&gt;.interopManager = &lt;span style="color:blue"&gt;new&lt;/span&gt; BackgroundCopyManager30() &lt;span style="color:blue"&gt;as&lt;/span&gt; IBackgroundCopyManager;
	&lt;span style="color:blue"&gt;if&lt;/span&gt;(&lt;span style="color:blue"&gt;this&lt;/span&gt;.interopManager != &lt;span style="color:blue"&gt;null&lt;/span&gt;)
		_version = BITSWrapper.BitsVersion.Bits3_0;
	&lt;span style="color:blue"&gt;else&lt;/span&gt;
		&lt;span style="color:blue"&gt;throw&lt;/span&gt; &lt;span style="color:blue"&gt;new&lt;/span&gt; NotSupportedException();
}
&lt;span style="color:blue"&gt;catch&lt;/span&gt;
{
	&lt;span style="color:blue"&gt;try&lt;/span&gt;
	{
		&lt;span style="color:blue"&gt;this&lt;/span&gt;.interopManager = &lt;span style="color:blue"&gt;new&lt;/span&gt; BackgroundCopyManager20() &lt;span style="color:blue"&gt;as&lt;/span&gt; IBackgroundCopyManager;
		&lt;span style="color:blue"&gt;if&lt;/span&gt;(&lt;span style="color:blue"&gt;this&lt;/span&gt;.interopManager != &lt;span style="color:blue"&gt;null&lt;/span&gt;)
			_version = BITSWrapper.BitsVersion.Bits2_0;
		&lt;span style="color:blue"&gt;else&lt;/span&gt;
			&lt;span style="color:blue"&gt;throw&lt;/span&gt; &lt;span style="color:blue"&gt;new&lt;/span&gt; NotSupportedException();
	}
	&lt;span style="color:blue"&gt;catch&lt;/span&gt;
	{
		&lt;span style="color:blue"&gt;try&lt;/span&gt;
		{
			&lt;span style="color:blue"&gt;this&lt;/span&gt;.interopManager = &lt;span style="color:blue"&gt;new&lt;/span&gt; BackgroundCopyManager15() &lt;span style="color:blue"&gt;as&lt;/span&gt; IBackgroundCopyManager;
			&lt;span style="color:blue"&gt;if&lt;/span&gt;(&lt;span style="color:blue"&gt;this&lt;/span&gt;.interopManager != &lt;span style="color:blue"&gt;null&lt;/span&gt;)
				_version = BITSWrapper.BitsVersion.Bits1_5;
			&lt;span style="color:blue"&gt;else&lt;/span&gt;
				&lt;span style="color:blue"&gt;throw&lt;/span&gt; &lt;span style="color:blue"&gt;new&lt;/span&gt; NotSupportedException();
		}
		&lt;span style="color:blue"&gt;catch&lt;/span&gt;
		{
			&lt;span style="color:blue"&gt;try&lt;/span&gt;
			{
				&lt;span style="color:blue"&gt;this&lt;/span&gt;.interopManager = &lt;span style="color:blue"&gt;new&lt;/span&gt; BackgroundCopyManager10() &lt;span style="color:blue"&gt;as&lt;/span&gt; IBackgroundCopyManager;
				&lt;span style="color:blue"&gt;if&lt;/span&gt;(&lt;span style="color:blue"&gt;this&lt;/span&gt;.interopManager != n&lt;span style="color:blue"&gt;ull&lt;/span&gt;)
					_version = BITSWrapper.BitsVersion.Bits1_0;
				&lt;span style="color:blue"&gt;else&lt;/span&gt;
					&lt;span style="color:blue"&gt;throw&lt;/span&gt; &lt;span style="color:blue"&gt;new&lt;/span&gt; NotSupportedException();
			}
			&lt;span style="color:blue"&gt;catch&lt;/span&gt;
			{
				&lt;span style="color:blue"&gt;throw&lt;/span&gt; &lt;span style="color:blue"&gt;new&lt;/span&gt; NotSupportedException(&lt;span style="color:#a31515"&gt;&amp;quot;The required 'Background Intelligent Transfer Service' library does not appear to be installed on this machine.&amp;quot;&lt;/span&gt;);
			}
		}
	}
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;</description><author>mldisibio</author><pubDate>Fri, 18 Jan 2013 20:34:52 GMT</pubDate><guid isPermaLink="false">New Post: IBackgroundCopyJob4 not implemented in Windows 8?  20130118083452P</guid></item></channel></rss>