Designer and Type Reflection Issue in early WF 4.0 bits
While I was working out some samples using WF 4.0 I ran into a tuple of bugs (yes, that is a soundex pun). I have a Receive activity where I have set the ValueType to x:String. The out argument is assigned to a string variable named Message. Subsequently, the variable Message is used in the WF. However, as initially built, with the settings correct I receive a compiler error, because the types are mismatched. This is due to the type being set incorrectly in the XAML by the designer. The XAML as generated is:
<Receive x:Name="__ReferenceID0" CanCreateInstance="True" CorrelatesWith="[handle]" DisplayName="Receive_Ping" OperationName="ServicePing" ServiceContractName="TestServiceContract" ValueType="x:String">
<Receive.AdditionalCorrelations>
<p:InArgument x:TypeArguments="CorrelationHandle" x:Key="ChannelBasedCorrelation">[handle]</p:InArgument>
</Receive.AdditionalCorrelations>
<Receive.KnownTypes>
<s:RuntimeType>x:Int32</s:RuntimeType>
</Receive.KnownTypes>
<p:OutArgument x:TypeArguments="s:Object">[Message]</p:OutArgument>
</Receive>
To fix the problem I simply need to change the type to x:String. However, that is not straight forward, because the designer regenerates the XAML every time. So, I have to close all designer windows for this file and then open it in another editor (Notepad) then edit, save, and close. Once I reopen the file the fields will show up properly with the correct type in the properties window and the code will all compile. So, depending on the build you are using you may have some designer issues with getting the proper type. Lastly, changing the type in the properties window will not update the underlying XAML whatsoever in the build I'm using. So, if you get some mismatches on types or have some type mismatches during execution you might want to open the XAML directly and review it to ensure that it is correctly typed.
Here is a edited screen shot showing the properties for the activities in a simple workflow. Note that for the ValueType property for the Receive Activity is set to string, but that is what shows up behind the scenes as s:Object.
Here is the image:
Comments
- Anonymous
April 27, 2009
PingBack from http://microsoft-sharepoint.simplynetdev.com/designer-and-type-reflection-issue-in-early-wf-40-bits/