Got error in "Invoke Code" Activity

Hi
I had Main.xaml where all workflow was defined. It had “Invoke Code” activity where in I had used AsEnumerable extension method for a Data Table. This code was running perfectly.
Now I chose “Extract Workflow” and made a new.xaml, so all my workflow went in new.xaml making Main.xaml empty.
Now I added new flowchart in main.xaml and added “Invoke Workflow File” activity and gave new.xaml path there.

I started getting below error for AsEnumerable.

I checked and verified at every activity level, System.Linq namespace is imported.
Why did I get this error then?

Hi,

I think you are having an issue that has cropped up elsewhere as well:

In short, the assembly containing the extensions may not have been loaded in the new workflow. You can probably cause it to be loaded by temporarily adding some DataTable activity, as this is probably how it got loaded in the original workflow.

Actually, I have decided to use my newfound powers to move your post to #issues. Could anyone confirm @andrzej.kniola’s diagnosis and could this be fixed?

1 Like

I don’t have 2017.1, but I can confirm that extracting a workflow seem to only put default assemblies there (and maybe those related to used activities, haven’t tested too deep). DataSetExtensions dll is not added.

@badita - did you consider adding it by default or giving a way of adding it other than using a method from it to force load it? Since it’s not a namespace, it’s a little bit confusing for a lot of people of why it’s not working.

As far as I remember you have to add the referenced assemblies in the Imports panel; see:

Let us know if it works.

Thanks,
Adrian.

Indeed, but this exactly where the (subtle) problem is: it sometimes misses out on declarations that are in the same namespace, but a different assembly. It is currently not clear whether certain extension assemblies are loaded, other than by querying IntelliSense or catching a compiler error with no clear solution.

1 Like

can I have the workflow or at least the relevant part of it?

Thanks,
Adrian.

Repro steps:

  1. Create new sequence workflow.
  2. Create a nested sequence inside of it (named inner for clarity).
  3. In inner create a DataTable variable named testDT.
  4. In inner add a WriteLine activity: testDT.AsEnumerable().Count().ToString()
    (at this point everything works)
  5. RMB click inner → select Extract as workflow, name new workflow inner
  6. In new workflow there will be a validation error ~.AsEnumerable() is not a member of System.Data.DataTable

extractionTest.xaml (4.8 KB)
inner.xaml (4.1 KB)

On examining .xaml content, following line is “missing” from inner.xaml:
<AssemblyReference>System.Data.DataSetExtensions</AssemblyReference>

This line gets added if the compiler finds usage of anything from that .dll (namespace is still System.Data), but only during actual writing of the code.
Since System.Data namespace is already present, it cannot be added.

/endrepro

Similar issue I think can happen with System.IO.Compression.FileSystem.dll, as it also has a shared namespace with System.IO.Compression.dll - see this topic.

2 Likes

Thank you very much!

If you are aware of more of this cases please share. We’ll have to add these dlls when compiling VB.net nocde in InvokeCode activity.

Adrian.

It seems to work fine when there’s an assembly reference in the .xaml that has the InvokeCode. It’s just that extracting to a workflow does not copy all references (which is good or bad, depending on how you look at it).
There’s a design decision to be made here and honestly I’d lean to ease of use side - overhead is already “high” (relatively speaking) and DataSetExtensions is quite extensively used, so I’d even go as far as to add it by default to xaml’s. That could also solve some issues with intellisense not working correctly until restart when this .dll is added.

But it’s your call :wink:

1 Like

I started with a blank workflow and System.Data namespace was already in the Imports list but still the VB.Net code failed to compile (because System.Data.DataSetExtensions.dll is needed). Extracting to a workflow is another story which I will test shortly.

Thanks,
Adrian.

1 Like

It gets added when you’re doing this step:
4. In inner add a WriteLine activity: testDT.AsEnumerable().Count().ToString()

As the compiler/interpreter recognizes that the user needs it. So there is something that does this already in place somewhere.

1 Like