1

Here is the scenario, discovered while trying to troubleshoot the same issue in the self hosted designer. Create a library project with a type in it. Mine is this.

namespace RaceEventLibrary
{
    public class Registration
    {
        public string Name { get; set; }
        public int Age { get; set; }
        public string EventName { get; set; }
    }
}

Now create a Workflow 4.5 console app (or service, it doesn't seem to matter). Reference the library project. Put a sequence on the designer and then make an InArgument of this library type, Registration in my case. All is fine, the designer is happy.

Next create another identical project, reference the same library. Now simply open the xaml file from the first project. Boom, it can't find the types.

System.Xaml.XamlException: 'The type ‘InArgument(r:Registration)’ of property ‘registration’ could not be resolved.'

This in the xaml is:

    <x:Members>
        <x:Property Name="registration" Type="InArgument(r:Registration)" />
    </x:Members>

preceded by 
    xmlns:r="clr-namespace:RaceEventLibrary;assembly=RaceEventLibrary"

With the self hosted designer I have been finding many variations of this issue and have tried various ways to get the library assembly loaded into the designer, but no joy.

Any suggestions of how to correct this?

Philip Nelson
  • 985
  • 6
  • 20
  • You'll want to debug this using the [Fusion log viewer.](http://msdn.microsoft.com/en-us/library/e74a18c4.aspx) Just make sure to run it as admin, turn on the log, and reboot before attempting to debug. You'll see where the CLR is looking for the assembly, and what version, and from there determine why it isn't being found (if you even have it installed). –  Nov 02 '12 at 12:59
  • Very strange. Did what you suggested and see many logs. But none for this issue. Since writing, I brought the offending workflow into the solution and can open it in the designer that way, no surprise there as all the files under obj folder are there. To be continued, but thanks for the suggestion. – Philip Nelson Nov 02 '12 at 15:57
  • Wait, you were just opening a file that isn't in the solution? That isn't supported, AFAIK. –  Nov 02 '12 at 17:14
  • That is my goal yes. If I can verify that I'll be closer to my next solution. I really just want to be able to show the flow and highlight some elements, no user interaction required. – Philip Nelson Nov 02 '12 at 18:44
  • The designer has to locate the assemblies referenced by your workflows. There is no way around that. If the type assemblies are already loaded in the AppDomain, there's no issue. That's why, in VS, it works--your references are loaded into the AD in which the WorkflowDesigner is instantiated. If those assemblies aren't loaded, and cannot be found through normal probing (the workflow xaml serializer may not go through fusion, that's something to investigate), then the workflow can't be opened. –  Nov 02 '12 at 19:42

1 Answers1

0

WF4 has it own ways of loading assemblies that is not always exactly the same as the standard .NET framework. Ron Jacobs did an interesting number of posts on that, see here for a start.

You don't mention how you actually load the workflow into the WorkflowDesigner. There are several ways of doing this. When using the ActivityXamlServices.CreateBuilderReader() you can specify using the XamlSchemaContext what assemblies are required. That should let you load the workflow.

Maurice
  • 27,582
  • 5
  • 49
  • 62
  • I had just been using WorkflowDesigner.Load(workflowFileName). Using your suggestion of loading the workflow, referencing the assembly like below works: `var reader = new XamlXmlReader(System.IO.File.OpenText(_workflowName)); Assembly assembly = Assembly.LoadFrom(@"somepath\RaceEventLibrary.dll"); IList assemblies = new List() { assembly }; var wf = ActivityXamlServices.CreateBuilderReader(reader, new XamlSchemaContext(assemblies)); WorkflowDesigner.Load(wf);` – Philip Nelson Jan 20 '13 at 14:43
  • sorry about the formatting. The only problem with this is that either the designer seems to have lost fidelity in the load or in some cases I get a blank window. Layout info (Points I think) seem to have gotten lost. – Philip Nelson Jan 20 '13 at 14:51