Search code examples
c#wpftypeloadexceptionworkflow-foundation-4.5

Rehosted Workflow Designer throws TypeLoadException upon Load


I'm trying to rehost the workflow designer in my WPF app.

However, when I try to initialise it I get a TypeLoadException dialog with the following message:

"Could not load type 'Reporting.Primitives.Documents.IDocField`1' from assembly 'Reporting.Primitives, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'."

I've tried stripping it down and have gotten to the simple invocation code here:

var wnd = new Window();
var grid = new Grid();
wnd.Content = grid;

var met = new DesignerMetadata();
met.Register();

var d = new WorkflowDesigner();
d.Load(new Sequence());
grid.Children.Add(d.View);
wnd.Show();

It is the call to Load that causes the exception.

Here's the weird part: There's no type in the solution called IDocField<T>.

There's an IDocField and a DocField<T> : IDocField, so it seems to be inventing this IDocField<T> type from somewhere.

I don't have any reflection calls looking for an IDocField<T> either.

I've also tried moving this code around the app into various modules that aren't directly referencing Reporting.Primitives to no avail.

There is an IUiDocField<T> interface floating around.

Curiously enough, I did write an interface IDocField<T> some time ago, but it's not in the solution now, so I don't see why it would be causing problems.


Solution

  • As usual It's always your (my) fault.

    The app pulls in plugins via a directory using reflection, and it appears there was an old dll in there that was referencing the IDocField<T> interface.

    It would seem that this wasn't a problem until the workflow designer attempted to probe the assembly for type information that something finally noticed it was referencing something that wasn't there!

    facepalm