"Specified cast is not valid" exception

Topics: Updater Application Block
Jul 6, 2005 at 8:06 AM
originally posted by: Tbili

I am using SimpleAppStart quickstart sample and I am getting "Specified cast is not valid" exception in SetBackgroundJobCredentials() in BitsDownloader.cs. I am not sure how this code could work:

IBackgroundCopyJob2 copyJob = (IBackgroundCopyJob2) backgroundCopyJob;

This is where the exception occurs since backgroundCopyJob is of type IBackgroundCopyJob. Just to try, I used IBackgroundCopyJob instead and the cast worked just fine. The backgroundCopyJob object is declared as IBackgroundCopyJob type and gets instantiated by calling copyManager.CreateJob() inside the CreateCopyJob method.
I did try to apply the patch for BitsDownloader.cs but it didn't seem to fix the issue.

Thanks,
Norton.
Jul 6, 2005 at 8:52 PM
originally posted by: SandyNarang

Hi Norton,

Please check the version of BITS(Background Intelligent Transfer Service) on your machine. IBackgroundCopyJob2 was made available from BITS v1.5 onwards.
Please visit the Updater FAQ at (http://www.gotdotnet.com/workspaces/customization/uploadedhtmlpage.aspx?FileID=30079388-48f2-4e66-9a45-54fc7f84e806&id=83c68646-befb-4586-ba9f-fdf1301902f5#q5) for details regarding how to check for BITS version.

I hope this helps.