IBackgroundCopyJob4 not implemented in Windows 8?

Dec 15, 2012 at 7:49 PM
Edited Dec 15, 2012 at 7:49 PM

When trying to read or write the properties of BitJob that delegate to properties of IBackgroundCopyJob4 I get a NotSupportedException. Is it possible that IBackgroundCopyJob4 is not implementet in the BITS version of Windows 7 and 8 (64 Bit, I tried both)?

When debugging I find that the job can be cast to IBackgroundCopyJob to IBackgroundCopyJob3, but not to IBackgroundCopyJob4.

Coordinator
Dec 16, 2012 at 7:43 AM

BitsManager has a property BitsVersion which would tell you about the (file) version of BITS installed on your machine. You may check what value you get there for your machines.

Dec 16, 2012 at 2:59 PM
Edited Dec 16, 2012 at 3:07 PM

Thanks for the reply. BitsVersion does not work with Windows 8 since the qmgr.dll version is 7.6. It returns Bits0_0. I don't even know which BITS version qmgr.dll version 7.6 is. It's not documented (at least I did not find it). According to the fact that qmgr.dll version 7.5 is BITS 4.0, IBackgroundCopyJob4 should be implemented (according to the documentation it was introduced in BITS 2.5).

I just tried to set MaximumDownloadTime of a BitsJob instance. This throws a NotSupportedException. I even tried on Windows 7 (64 Bit) and got the same result.

Could it be a 64 Bit problem? I will try on Windows 7, 32 Bit to be sure.


Coordinator
Dec 17, 2012 at 3:38 PM

good point, never did any test under Win8 so far, and haven't noticed the change in version numbers. And since documentation isn't updated/changed I assume there is no change in functionality, but worth to follow up and also test in Win8.

Shouldn't be an x64 issue, as the code has been tested/running in x64 environments (and few related bugs were fixed....)

Dec 20, 2012 at 1:19 PM
Edited Jan 22, 2013 at 7:21 AM

i don't think that it is a Win8 or x64 issue. Look at the interop code. The definition is:

 

    #region IBackgroundCopyJob4
    /// <summary>
	/// Use this interface to enable peer caching, restrict download time, and inspect user token characteristics.
	/// </summary>
	[ComImport]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	[Guid("BC2C92DF-4972-4FA7-B8A0-444E127BA670")]
	internal interface IBackgroundCopyJob4
 

 

But according to Windows documentation (http://msdn.microsoft.com/de-de/library/windows/desktop/aa362995%28v=vs.85%29.aspx) it should be

 

    #region IBackgroundCopyJob4
    /// 
	/// Use this interface to enable peer caching, restrict download time, and inspect user token characteristics.
	/// 
	[ComImport]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	[Guid("659cdeae-489e-11d9-a9cd-000d56965251")]
	internal interface IBackgroundCopyJob4

The difference is the Guid. I've changed it in sources and on my System the IBackgroundCopyJob4 is working as expected.

 

 

 

Jan 18, 2013 at 7:34 PM
Edited Jan 18, 2013 at 7:41 PM

Just wanted to confirm that I had the same exact problem and fixed it by correcting the Guid.

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:

 

readonly BitsVersion _version = BITSWrapper.BitsVersion.Bits0_0;
try
{
	this.interopManager = new BackgroundCopyManager30() as IBackgroundCopyManager;
	if(this.interopManager != null)
		_version = BITSWrapper.BitsVersion.Bits3_0;
	else
		throw new NotSupportedException();
}
catch
{
	try
	{
		this.interopManager = new BackgroundCopyManager20() as IBackgroundCopyManager;
		if(this.interopManager != null)
			_version = BITSWrapper.BitsVersion.Bits2_0;
		else
			throw new NotSupportedException();
	}
	catch
	{
		try
		{
			this.interopManager = new BackgroundCopyManager15() as IBackgroundCopyManager;
			if(this.interopManager != null)
				_version = BITSWrapper.BitsVersion.Bits1_5;
			else
				throw new NotSupportedException();
		}
		catch
		{
			try
			{
				this.interopManager = new BackgroundCopyManager10() as IBackgroundCopyManager;
				if(this.interopManager != null)
					_version = BITSWrapper.BitsVersion.Bits1_0;
				else
					throw new NotSupportedException();
			}
			catch
			{
				throw new NotSupportedException("The required 'Background Intelligent Transfer Service' library does not appear to be installed on this machine.");
			}
		}
	}
}
Coordinator
Jan 21, 2013 at 3:30 PM

sounds like there is some need for improvement. I'll have those fixed incorporated in the source and publish an updated version.