This project is read-only.

InvalidCastException

Jul 2, 2014 at 6:11 PM
I've downloaded from nuget, tried downloading from codeplex and even tried using a dll from the demo project but each time I try creating a BitManager:
BitsManager manager = new BitsManager();
I get the following error:

Unable to cast object of type 'BackgroundCopyManager.BackgroundCopyManagerClass' to type 'SharpBits.Base.BackgroundCopyManager'.

Happens on the 3rd line of the BitsManager constructor:
        public BitsManager()
        {
            // Set threading apartment
            System.Threading.Thread.CurrentThread.TrySetApartmentState(ApartmentState.STA);
            int hResult = NativeMethods.CoInitializeSecurity(IntPtr.Zero, -1, IntPtr.Zero, IntPtr.Zero, RpcAuthnLevel.Connect, RpcImpLevel.Impersonate, IntPtr.Zero, EoAuthnCap.None, IntPtr.Zero); 

            this.manager = new BackgroundCopyManager() as IBackgroundCopyManager;
Any help on this?
Jul 3, 2014 at 10:10 AM
So this only happens when called from a unit test project
Jul 3, 2014 at 11:33 AM
what user account is the unit test running, is this some automated test running on build server?
Jul 4, 2014 at 11:50 AM
No, it is just a unit test run from Visual Studio, I could not get it to work with TFS so downloaded NUnit and it all worked. Not idea what the underlying issue was.