none
Hosted Designer: InvokeMethod:Target Type - Browse For Types... Any DLL Path RRS feed

  • Question

  • Created a WPF application which has hosted designer of workflow.

    Hosted Designer Scenario:

    InvokeMethod is able to invoke static and instance methods of a dll which are present in the specific location.

    What is the specific location? For Example:When I select "Browse For Types.." value of a TargetType property of Invoke method.A window/Form is opened which allows you to "Browse and Select a .Net Type".

    Do I need to copy external dll to a specific location,so that dll classes and methods are visible in "Browse and Select a .Net Type."?

    As of now,I can invoke methods which are present in my project namespace and predefined Microsoft reference Assembilies.

    My requirement is to invoke methods of a dll which are present in any location. Can it be achieved through some settings?
    Wednesday, November 18, 2009 6:16 AM

Answers

  • For a rehosted application, I think AssemblyContextControlItem might do what you need:

    http://msdn.microsoft.com/en-us/library/system.activities.presentation.hosting.assemblycontextcontrolitem(VS.100).aspx

    You get or set the item using the designer's EditingContext.

    Tim

    • Marked as answer by sans_india85 Wednesday, November 18, 2009 10:16 AM
    • Unmarked as answer by sans_india85 Thursday, November 19, 2009 7:31 AM
    • Marked as answer by sans_india85 Friday, November 20, 2009 4:55 AM
    Wednesday, November 18, 2009 7:28 AM
    Moderator
  • I think what you want to do is make use of the VBSettings class.  This class passes on assembly information into the expression editor.  That being said, the assembly needs to be in a discoverable palce (ie: The GAC, or in the same folder as the executable).  Try out the following code sample.

    WorkflowDesigner designer;

    ActivityBuilder ab = new ActivityBuilder() {Implementation = new Sequence()};
    VisualBasicSettings settings = new VisualBasicSettings();
    settings.ImportReferences.Add(
    new VisualBasicImportReference() { Assembly = "<Your assembly name>", Import = "<A namespace in the assembly>" });
    VisualBasic.SetSettings(ab, settings);
    this.designer = new WorkflowDesigner();
    this.designer.Load(ab);

    Thanks,
    Eric

    <edited to fix formatting>

    • Marked as answer by sans_india85 Friday, November 20, 2009 11:02 AM
    Thursday, November 19, 2009 9:14 PM

All replies

  • For a rehosted application, I think AssemblyContextControlItem might do what you need:

    http://msdn.microsoft.com/en-us/library/system.activities.presentation.hosting.assemblycontextcontrolitem(VS.100).aspx

    You get or set the item using the designer's EditingContext.

    Tim

    • Marked as answer by sans_india85 Wednesday, November 18, 2009 10:16 AM
    • Unmarked as answer by sans_india85 Thursday, November 19, 2009 7:31 AM
    • Marked as answer by sans_india85 Friday, November 20, 2009 4:55 AM
    Wednesday, November 18, 2009 7:28 AM
    Moderator
  • Thanks tilovell for precise link.

    Problem solved for Invoke method : TargetType property using the below code. Iam able to see and use Sample assembly in "Browse and Select .Net Type".

    AssemblyContextControlItem acci = new AssemblyContextControlItem();
    acci.LocalAssemblyName = new AssemblyName(Assembly.LoadFile("c:\\Sample.dll").FullName);

    But Iam unable to use "Sample" assembly  for InvokeMethod: TargetObject property.The error message thrown by expression editor of TargetObject property is "Compiler error(s) encountered processing "new Sample.MathUtility".Type 'Sample.MathUtility' is not defined.

    How ro resolve this problem w.r.t ExpressionEditor?

    Thursday, November 19, 2009 7:49 AM
  • I think what you want to do is make use of the VBSettings class.  This class passes on assembly information into the expression editor.  That being said, the assembly needs to be in a discoverable palce (ie: The GAC, or in the same folder as the executable).  Try out the following code sample.

    WorkflowDesigner designer;

    ActivityBuilder ab = new ActivityBuilder() {Implementation = new Sequence()};
    VisualBasicSettings settings = new VisualBasicSettings();
    settings.ImportReferences.Add(
    new VisualBasicImportReference() { Assembly = "<Your assembly name>", Import = "<A namespace in the assembly>" });
    VisualBasic.SetSettings(ab, settings);
    this.designer = new WorkflowDesigner();
    this.designer.Load(ab);

    Thanks,
    Eric

    <edited to fix formatting>

    • Marked as answer by sans_india85 Friday, November 20, 2009 11:02 AM
    Thursday, November 19, 2009 9:14 PM
  • Hi EriWong,

    Problem solved!

    Thanks,
    Sandeep
    Friday, November 20, 2009 11:04 AM
  • Is it possible to remove one that has been loaded by AssemblyContextControlItem?
    Wednesday, December 8, 2010 3:40 AM