I have a Windows Workflow Foundation 4.5 WCF Workflow Service Application. I am attempting to return a Dictionary<IEdmEntityType, DataTable>
from my CodeActivity<Dictionary<IEdmEntityType, DataTable>>
. The code does not encounter a compile time error, but the XAML fails to compile.
The relevant parts of my XAML are like so:
We have the variable declarations for the sequence, where I am trying to dump my return value. The variable we're trying to assign to is called EntityTableRelationships
.
<p1:Sequence.Variables>
<p1:Variable x:TypeArguments="x:String" Name="MetadataContent" />
<p1:Variable x:TypeArguments="scg:Dictionary(mde:IEdmEntityType, sd:DataTable)" Name="EntityTableRelationships" />
</p1:Sequence.Variables>
There is also the OutArgument
, the return value from Execute
, from our CodeActivity<..>
being assigned to EntityTableRelationships
.
<o:TransformMetadataToTables.Result>
<p1:OutArgument x:TypeArguments="scg:Dictionary(mde:IEdmEntityType, sd:DataTable)">
<mca:CSharpReference x:TypeArguments="scg:Dictionary(mde:IEdmEntityType, sd:DataTable)">EntityTableRelationships</mca:CSharpReference>
</p1:OutArgument>
</o:TransformMetadataToTables.Result>
The XAML validation error being produced is:
Type 'http://schemas.microsoft.com/netfx/2009/xaml/activities:OutArgument(Dictionary)' is not assignable to type 'http://schemas.microsoft.com/netfx/2009/xaml/activities:OutArgument(Dictionary)' of member 'EntityTableRelationships'.
Initially I had thought that I typed my return value incorrectly or maybe I was referencing an interface with the same name but in a different namespace. This is not the case.
Another thought I had was that maybe the workflows do not play nice with any Dictionary<TKey, TValue>
declaring TKey
as any interface. I made a test case that does this and it worked fine. I also added that step into the designer and in a sequence, just as is done here. I did not try it with IEdmEntityType
as the TKey
, but there is no reason, that I can see, as to why it should be any different.
What could be the cause of this and how can I fix it?
EDIT #1
Further research has indicated that the DataTable
is the culprit. DataSet
also has the problem. The only thing I can see that is unique about these types is that they inherit from MarshalByValueComponent
which has a TypeConverterAttribute
on it. That TypeConverter
could be influencing the XAML serialization binder and causing issues, thus indicating a bug in WF 4.5. But, I am hesitant to say this is a bug.
No Dictionary<TKey, DataTable>
can be passed around in WF 4.5 via the designer, it seems.
EDIT #2
It seems it may or may not have anything to do with the DataTable
. You also cannot pass around Dictionary<IEdmEntityType, object>
.
To try and reproduce the issue with classes outside of System.Data
and other than System.Object
, I made a new workflow project.
I created my own interface, classes, and structs to see if there was anything that would trigger it to break again.
Instead of using IEdmEntityType
, I made IMyInterface
which is just defined as:
public interface IMyInterface
{
int Id
{
get;
}
}
The MyStruct
struct worked fine. This is the definition:
public struct MyStruct
{
public int A;
public int B;
}
The MyClass
class worked fine. This is the definition:
public class MyClass
{
public int A;
public int B;
}
MyClassComplex
with automatic properties and a reference to an object
also worked.
public class MyClassComplex
{
public int A
{
get;
private set;
}
public int B
{
get;
private set;
}
public object C
{
get;
private set;
}
}
I also thought originally that it might have something to do with the common attributes between DataTable
and DataSet
, so I added them to MyClassComplex
, but it still worked fine.
Additionally, I had MyClassComplex
inherit from MarshalByValueComponent
, and there was no odd interaction, no errors once again.
I took this same project and simply set my variable as a Dictionary<IMyInterface, DataTable>
and altered the CodeActivity<IMyInterface, MyClassComplex>
to CodeActivity<IMyInterface, DataTable>
, and it gave the same error as in my original non-test project.
EDIT #3
Since I have tested this and reproduced the issue in separate projects and on a colleague's machine and no documentation supports why this should not work, I have filed a bug report on MS Connect
Apparently Windows Workflow Foundation includes a specific version of Microsoft.Data.OData
and adding the ODataLib NuGet package to the project conflicts with that. I searched around for where the reference is included originally and it turns out it is silently added during code generation as part of the workflow designer's code generation process.
At no point was there any error on the client side that indicated some assembly version conflict. As far as I know, there's no way to get around this. Microsoft has closed the ticket as "by design".
Just for simplify the case, it also happens if you try to assign double value/variable to a double variable. It was working before 4.5 but now it does not.
Non touched Wf definitions just stop working upgrading the framework.
We have solved it manually modifying .xaml from x:Object to x:Double in both Target and Origin variables from the Assign activity.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.