locked
Add my custom Activity to the Toolbox from a DLL RRS feed

  • Question

  • Hi All,

    I'm trying to add my custom activity from dll to the Toolbox during installation.
    My custom activity is a part of my product, so I am going to install my custom activity to the client PC.

    My custom activity is presented as couple libraries: MyActivityCore.dll, MyActivityView.dll (the library MyActivityView.dll contains Activity class and has reference to the MyActivityCore.dll)

    I need a some way to install my custom activity automatically from my installer.

    The similar old question has dead link to the post with the solution:
    http://social.msdn.microsoft.com/Forums/vstudio/en-US/c4b47ab3-e1f2-440e-93b3-21181fe6c040

    In the question (http://social.msdn.microsoft.com/Forums/vstudio/en-US/699153a8-a013-4b70-ac57-206e3fc5aaa1), I've found useful link to the post http://www.west-wind.com/wconnect/weblog/ShowEntry.blog?id=474

    But I did not managed to add my custom activity to the ToolBox.

    I've done:
    1. Create MyActivity.vscontent file:
    <?xml version="1.0" encoding="utf-8"?>
    <VSContent xmlns="http://schemas.microsoft.com/developer/vscontent/2005">
        <Content>
            <FileName>ToolboxControl\MyActivityView.dll</FileName>
            <DisplayName>MyActivity</DisplayName>
            <Description>MyActivity</Description>
            <FileContentType>Toolbox Control</FileContentType>
            <ContentVersion>1.0</ContentVersion>
        </Content>
    </VSContent>
    2. I've created folder 'ToolboxControl' and copied MyActivityCore.dll, MyActivityView.dll to this one.
    3. Compress the file MyActivity.vscontent and the folder 'ToolboxControl' to the file MyActivity.zip
    4. Rename the MyActivity.zip to the MyActivity.vsi
    5. Install MyActivity.vsi through the VS Content Installer. Installer has installed my custom activity.
    6. Run Visual Studio and create a new ActivityLibrary solution.
    7. Open the ToolBox

    There is no my custom activity in the ToolBox

    What have i done wrong ?

    Perhaps, There are some other best solution for my question except to create VSI file.

    Question:
    How to add my custom activity from dll to the Toolbox during installation ?

    Thanks for your support
    Tuesday, December 17, 2013 10:52 AM

Answers

All replies

  • Hi,

    I saw the answer in the discussion which might helpfull:

    #install custom activity with code:

    if (File.Exists(Path.Combine(libPath, @"Myproject.dll")))
       {    
        string myTab = "MyTab";
        EnvDTE.Window window = dte.Windows.Item(EnvDTEConstants.vsWindowKindToolbox);
        EnvDTE.ToolBox toolbox = (EnvDTE.ToolBox)window.Object;
        ToolBoxTab initialTab = toolbox.ActiveTab;
        EnvDTE.ToolBoxTab myTab = null;
        foreach (ToolBoxTab tab in toolbox.ToolBoxTabs)
        {
         if (tab.Name.ToUpper() == myTab.ToUpper())
         {
          myTab = tab;
          break;
         }
        }
    
        if (myTab != null)
        {
         myTab.Delete();
        }
    
        myTab = toolbox.ToolBoxTabs.Add(myTab);
        myTab.Activate();
    
        var asm  = Assembly.LoadFrom(Path.Combine(libPath, @"Myproject.dll"));
    
        var types  = from t in asm.GetExportedTypes()
           wheretypeof(Activity).IsAssignableFrom(t)
           select t;
    
        if (types != null && types.Count() > 0)
        {
         foreach (var item  in types)
         {
          var dataObject = new OleDataObject();
          dataObject.SetData("AssemblyName", asm.GetName());
          dataObject.SetData("CF_WORKFLOW_4", item.Name);
          dataObject.SetData("WorkflowItemTypeNameFormat", item.AssemblyQualifiedName);
          myTab.ToolBoxItems.Add(item.Name, dataObject, vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent);
         }
        }
       }
    

    For more information, you can refer here

    http://go4answers.webhost4life.com/Example/custom-wf4-activities-toolbox-code-81634.aspx


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

    Wednesday, December 18, 2013 7:14 AM
  • I'm not sure, but It looks like what I need.

    I have not managed to run this code.

    - I didn't figure out how to initialize 'dte' variable in this example (EnvDTE.Window window = dte.Windows.Item(EnvDTEConstants.vsWindowKindToolbox))
      How to initialize 'dte' variable ?

    The OleDataObject class according to the  http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.oledataobject(v=vs.120).aspx
    presents in the Microsoft.VisualStudio.Shell. I could not find reference to the Microsoft.VisualStudio.Shell  in the Visual Studio->Project->Add Reference..-> Assemblies->Extensions. There is Microsoft.VisualStudio.Shell.Interop instead of Microsoft.VisualStudio.Shell
    - Which reference should I add to the project to use the class OleDataObject ?

    Thanks a lot

    • Edited by mperever Thursday, December 19, 2013 8:19 AM Add more details about OleDataObject
    Thursday, December 19, 2013 8:02 AM
  • Hi,

    Please refer the blog: it said the reason I had two project files in a single directory was because it’s the default configuration when using LLBLGEN (adapter mode).  

    For more information, you can refer here

    http://www.rohland.co.za/index.php/2010/06/08/workflow-4-0-custom-activities-not-appearing-in-the-vs2010-toolbox/

    http://social.msdn.microsoft.com/Forums/en-US/fc6a3399-267c-4485-a220-04afb744abdb/cant-add-custom-activities-in-toolbox-if-using-solution-folders?forum=wfprerelease

    Hope it can help you.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

    • Marked as answer by mperever Thursday, January 9, 2014 7:11 AM
    Monday, December 30, 2013 8:57 AM