We've built a custom workflow component to scan a given directory for ZIP files, create a directory to extract the files into, extract the files to the directory, and then process the files. As part of this, we're using Microsoft Shell Controls and Automation COM to handle extracting the contents of the zipfile.
The code itself works fine, but throws errors when we execute it through Workflow. Here is the code that fails in workflow.
Dim sc As New Shell32.Shell Dim output As Shell32.Folder = sc.NameSpace(di.FullName) Dim input As Shell32.Folder = sc.NameSpace(archive.FullName) output.CopyHere(input.Items, 4)
The code fails on "output.CopyHere" with the following error:
Unable to cast COM object of type 'System.__ComObject' to interface type 'Shell32.Shell'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{286E6F1B-7113-4355-9562-96B7E9D64C54}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
I've confirmed that the library is on the server (Windows Server 2008 R2) and that the code runs if we execute a console-version directly on the server.
I've also confirmed that the workflow user account has appropriate permissions to create the destination directory (that function having been done immediately prior to code example above)
From what I can tell - it seems as if Workflow is having problems executing the Shell commands. It doesn't error on the declaration of the input and output folders, only on the CopyHere method.
NOTE: The component is in .NET 4.0. We'd normally use .NET4.5 which has ZIP support built-in, but the System.Workflow.ComponentModel.ActivityExecutionContext is obsolete in .NET4.5. If there is an updated Workflow Activity template for VS2012+ that uses .NET4.5, that could help out.
Thanks!