You are viewing limited content. For full access, please sign in.

Question

Question

Using "Microsoft Shell Controls And Automation" COM in a workflow, having problems

asked on September 22, 2014 Show version history

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!

 

0 0

Answer

SELECTED ANSWER
replied on September 23, 2014

1) It would be easiest to use a script in this case.

2) Workflow is slated for a .NET framework upgrade in its next major release which doesn't currently have a release date (not the upcoming 9.2 release).

3) The warnings shouldn't hurt anything (You could suppress it) but I don't know what other issues you may run into including a .NET 4.5 targeted assembly (probably none, but I've never done it).

 

 

1 0

Replies

replied on September 22, 2014

 

We also tried refactoring the code using older syntax

Dim ShellAppType As Type = Type.GetTypeFromProgID("Shell.Application")
Dim objShell As Object = Activator.CreateInstance(ShellAppType)

Dim input = objShell.NameSpace((archive.FullName))
Dim output As Shell32.Folder = objShell.NameSpace((di.FullName))

output.CopyHere(input.Items, 20)

Instead of immediately erroring, the workflow just hung there. We had to manually force a stop (and in one case, reboot the workflow server).

0 0
replied on September 22, 2014

Is the Workflow x64?  It looks like the Microsoft Shell Controls and Automation COM is x86, so I beleive this means that it would not be available directly from/in a Workflow x64 activity.  Is it possible to create a console utility that is called from your activity and pass the zip and destination folder paths as arguments?

0 0
replied on September 22, 2014

The workflow is compiled for x86, but that is one of the things I checked as part of the troubleshooting.

We could do a console utility, and we've verified that a console app would run on the server without any issues. But if I'm doing that - I might as well just schedule the utility through Task Scheduler and not use LF Workflow. My manager realty wants to use LF Workflow - hence my challenge.

0 0
replied on September 22, 2014

As a windows service, workflow will probably always have issues running shell commands because shell commands expect being in an interactive process (a process that can show a UI). I would say that is why the 'older syntax' hangs, windows is showing a (error) dialog somewhere no one can access. 

You should try specifying option flags 512, and 1024 as well (http://msdn.microsoft.com/en-us/library/windows/desktop/bb787866(v=vs.85).aspx)

You could also try some of the suggestions here: http://superuser.com/questions/415204/how-do-i-allow-interactive-services-in-windows-7

 

 

 

 

 

0 0
replied on September 23, 2014

The 'older syntax' uses '20' for it's option flag (4 + 16). Option flag 16 automatically specifies "yes" for any dialogs, so I wouldn't have expected that to be a problem. That said, we haven't tried with 512 or 1024, so those options could be worth exploring.

Based on the responses - I take it that there really aren't any options with respect to workflow or workflow account permissions that could be causing this issue? I was really hoping for some type of permission setting or 'just use this code and it will work' type of answer.

0 0
replied on September 23, 2014 Show version history

Well for a simple answer, I just gave the .NET 4.5 libraries a try inside the script editor and they worked since they really are part of the .NET 4.0 framework that visual studio says you can't use unless targeting .NET 4.5. 

Add a reference to System.IO.Compression, and System.IO.Compression.FileSystem. 

 

Also add a  using statement to: System.IO.Compression

My code:

ZipFile.ExtractToDirectory(sourceZipFile, destinationFolder);

 

 

0 0
replied on September 23, 2014 Show version history

You're correct about .NET 4.5 having native ZIP functions, and those would handily solve my problem.  However, I didn't think you could use .NET4.5 in a Laserfiche Workflow Activity due to deprecation of some types

When I set the framework to .NET 4.5, I get the following warnings

'System.Workflow.ComponentModel.ActivityExecutionContext' is obsolete: 
'The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*'.

'System.Workflow.ComponentModel.ActivityExecutionStatus' is obsolete: 
'The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*'.

I guess I need to then ask if there are any problems with using .NET 4.5 for a Laserfiche Workflow Activity even with those warnings.

0 0
SELECTED ANSWER
replied on September 23, 2014

1) It would be easiest to use a script in this case.

2) Workflow is slated for a .NET framework upgrade in its next major release which doesn't currently have a release date (not the upcoming 9.2 release).

3) The warnings shouldn't hurt anything (You could suppress it) but I don't know what other issues you may run into including a .NET 4.5 targeted assembly (probably none, but I've never done it).

 

 

1 0
replied on September 23, 2014

Well miracle of miracles, .NET 4.5 does seem to work within a workflow activity, even with the obsolete warnings. Shame on me for not having actually tried it. Thanks a lot, Ed!

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.