locked
Namespace resolution issue when loading activities designed in VS2010 in rehosted WorkflowDesigner RRS feed

  • Question

  • Hi.

    I have activities that is made in VS2010, that are to be used in a rehosted WorkflowDesigner app. In the rehosted app I have a WorkflowDesigner, a toolbox with all the standard and my custom activities, and a property window. The problem occures when I load a composite activity that has reference to other custom activities (and that is drawn in the designer in VS2010). In the rehosted app the composite activity is shown almost as expected, except that all the referenced activities are shown in the designer as a red error message: "Activity could not be loaded because of errors in the XAML."  If I load the same activity in VS2010 it works.  If I remove the referenced activity in the rehosted app and adds it from the toolbox there, it works. If I draw the composite activity in the rehosted app from "the ground up", it works.

    If I compare the activity XAML that is saved in VS2010, and the activity XAML when opened, modified and saved in the rehosted app, I find differences in how namespaces are expressed:

    The Activity-XAML from VS2010 has namespace resolution at the top: xmlns:local="clr-namespace:WCFWorkflowPOC"

    The Activity-XAML from the rehosted app does not save namespace resolution at the top.

    If I add the activity in the rehosted app insted of in VS2010, it places namespace resolution at the referenced activity instead of globally at the top of the XAML:

    <local:MyActivity sap:VirtualizedContainerService.HintSize="200,22" ret="[ret]" xmlns:local="clr-namespace:WCFWorkflowPOC" />

    So, I may draw composite activities in VS 2010 OR in the rehosted app, but I may not share them across.

    Anyone who can help me figure out how to solve this? Thanks in advance.

    Wednesday, September 15, 2010 12:45 PM

Answers

  • Hi Hakon,

     

    I apologize for the delay in getting back to you.

     

    According to the product group, we’ll always serialize namespace defined in current project *without* assembly information. While in rehost, if AssemblyContextControlItem.LocalAssemblyName is null, we’ll always serialize namespace *with* assembly info) and this is required to get XAML deserialized correctly in rehost too.

     

    So for your case (creates a XAML referencing another XAML defined in the same project in VS), it’s by design that you cannot open it in rehost. Because there’s no assembly info there. But namespace got defined in the middle rather than top is not expected.  I tried the following steps but cannot repro it

    1)      Run rehost project

    2)      Delete the error red block and add a SharedCustomActivity

     

    This is the generated XAML which is correct, please let me know if I missed anything here.

     

    <Activity mc:Ignorable="sap"
              x:Class="ActivityLibrary1.CreatedInVS2010Activity"
              sap:VirtualizedContainerService.HintSize="262,240"
              mva:VisualBasic.Settings="Assembly references and imported namespaces for internal implementation"
              xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
              xmlns:a="clr-namespace:ActivityLibrary1;assembly=ActivityLibrary1"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
              xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System"
              xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities"
              xmlns:s="clr-namespace:System;assembly=mscorlib"
              xmlns:s1="clr-namespace:System;assembly=System"
              xmlns:s2="clr-namespace:System;assembly=System.Xml"
              xmlns:s3="clr-namespace:System;assembly=System.Core"
              xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities"
              xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
              xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System"
              xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel"
              xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.Core"
              xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=mscorlib"
              xmlns:sd="clr-namespace:System.Data;assembly=System.Data"
              xmlns:sl="clr-namespace:System.Linq;assembly=System.Core"
              xmlns:st="clr-namespace:System.Text;assembly=mscorlib"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
      <Sequence sad:XamlDebuggerXmlReader.FileName="C:\Diverse\WF4\CustomWorkflowDesigner\ActivityLibrary1\CreatedInVS2010Activity.xaml"
                sap:VirtualizedContainerService.HintSize="222,200">
        <sap:WorkflowViewStateService.ViewState>
          <scg3:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
          </scg3:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
        <a:SharedCustomActivity sap:VirtualizedContainerService.HintSize="200,22" />
      </Sequence>
    </Activity>

     

    Hope this helps!

     

    Best Regards,

    Zafar

    Wednesday, November 3, 2010 3:46 PM

All replies

  • Hi Hakon,

    Do you have a repro that you can share with us? If yes, please send it to me at cts-mimran@live.com .

    Best Regards,

    Zafar

    Tuesday, September 21, 2010 8:08 PM
  • I have sent you an example solution. Thank you.
    Wednesday, September 22, 2010 12:47 PM
  • Hi Hakon,

     

    I apologize for the delay in getting back to you.

     

    According to the product group, we’ll always serialize namespace defined in current project *without* assembly information. While in rehost, if AssemblyContextControlItem.LocalAssemblyName is null, we’ll always serialize namespace *with* assembly info) and this is required to get XAML deserialized correctly in rehost too.

     

    So for your case (creates a XAML referencing another XAML defined in the same project in VS), it’s by design that you cannot open it in rehost. Because there’s no assembly info there. But namespace got defined in the middle rather than top is not expected.  I tried the following steps but cannot repro it

    1)      Run rehost project

    2)      Delete the error red block and add a SharedCustomActivity

     

    This is the generated XAML which is correct, please let me know if I missed anything here.

     

    <Activity mc:Ignorable="sap"
              x:Class="ActivityLibrary1.CreatedInVS2010Activity"
              sap:VirtualizedContainerService.HintSize="262,240"
              mva:VisualBasic.Settings="Assembly references and imported namespaces for internal implementation"
              xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
              xmlns:a="clr-namespace:ActivityLibrary1;assembly=ActivityLibrary1"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
              xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System"
              xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities"
              xmlns:s="clr-namespace:System;assembly=mscorlib"
              xmlns:s1="clr-namespace:System;assembly=System"
              xmlns:s2="clr-namespace:System;assembly=System.Xml"
              xmlns:s3="clr-namespace:System;assembly=System.Core"
              xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities"
              xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
              xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System"
              xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel"
              xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.Core"
              xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=mscorlib"
              xmlns:sd="clr-namespace:System.Data;assembly=System.Data"
              xmlns:sl="clr-namespace:System.Linq;assembly=System.Core"
              xmlns:st="clr-namespace:System.Text;assembly=mscorlib"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
      <Sequence sad:XamlDebuggerXmlReader.FileName="C:\Diverse\WF4\CustomWorkflowDesigner\ActivityLibrary1\CreatedInVS2010Activity.xaml"
                sap:VirtualizedContainerService.HintSize="222,200">
        <sap:WorkflowViewStateService.ViewState>
          <scg3:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
          </scg3:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
        <a:SharedCustomActivity sap:VirtualizedContainerService.HintSize="200,22" />
      </Sequence>
    </Activity>

     

    Hope this helps!

     

    Best Regards,

    Zafar

    Wednesday, November 3, 2010 3:46 PM
  • Hi I have the same problem, and I didnt really understand your answer. Is there a solution? Thanks
    Sunday, March 6, 2011 1:46 PM
  • I have tried putting my activities assembly in the GAC but that did not make any difference. Anyone have any ideas on how to solve this? Thanks
    Monday, March 7, 2011 2:23 PM
  • Hi Hakon,

    I faced same sort of problem , following steps I made to resolve this issue.

    1. Create new project (assembly) and make all activities  in newly create project

    2. Create new project (assembly) and make all workflow that project

    3.Both have different namespaces.

    4. Modify "XAML"of edit your existing Workflow activity file in XML Editor and replace the local namespace as per instructions given in Zafar Response.

    xmlns:a="clr-namespace:ActivityLibrary1;assembly=ActivityLibrary1"

    Problem reason:

    Actually Re-host application unable to resolve the namespace , is it did not recognize the local assemble as mentioned by "Zafar".

    Why you want to put your assembly in GAC is there any specific requirement?

    Saturday, April 4, 2015 6:48 AM