简体   繁体   中英

A Workflow Foundation 4 argument of a nested type

One of the arguments to my workflow (xaml) is a nested type declared in a static class. Unfortunately, the "Browse for .NET type" dialog box does not show me this type irrespective of what I search for

full.namespace.containingstaticlass.typeIneed

or

full.namespace.containingstaticlass+typeIneed

Since the dialog didn't work, I tried editing the xaml itself but couldn't figure out how to define the

Type="InArgument(xmlnamespacetomyassembly:???)"

Help!?

Edit: It seems the Workflow Designer does not work with nested types at all, because an expression to cast an object to a nested type gave me this error.

在此处输入图片说明

At this point, any workarounds will be most welcome!

Added a simple sample that shows the problem.

  1. There is no way to add a parameter (in the designer) of type NestedType.EssentialStruct
  2. Even if you add an expression to cast Object to NestedType.EssentialStruct in the properties window against any InArgument, the designer will complain.

Posting the relevant sections also:

The nested type that needs to be used in the CodeActivity

public static class NestedTypes
{
    public struct EssentialStruct
    {
    }
}

A simple activity that uses the nested type as an InArgument and result

public sealed class TestActivity : CodeActivity<NestedTypes.EssentialStruct>
{
    public InArgument<NestedTypes.EssentialStruct> Handle
    {
        get;
        set;
    }

    protected override NestedTypes.EssentialStruct Execute(CodeActivityContext context)
    {
        return context.GetValue(this.Handle);
    }
}

I can't post the XAML that produces the error because the designer doesn't save it, errors out just before saving it.

You need to use import on the workflow. It's a tab in the designer. It's next to variables and arguments.

Check that the referenced assembly is built in x86 (or Any CPU). I had the same problem and it turned out that the referenced DLL was x64 which made it so the Visual Studio designer couldn't see it.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM