locked
How to display an assembly in the "Add Reference" dialog box RRS feed

  • Question

  • Hi,

    I want to craete a setup for adding the class library which i have created ,to the add reference dialog box.i.e when i create a new application I want the class library to be displayed in the Add Reference dialog box without browsing the dll.

    Please provide references for the above mentioned problem

    Thanks in advance

    Friday, November 27, 2009 11:38 AM

Answers

  • See:

    How to display an assembly in the "Add Reference" dialog box
    http://support.microsoft.com/kb/306149
    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about VS extensibility: http://msmvps.com/blogs/carlosq/
    • Proposed as answer by Carlos J. Quintero Friday, November 27, 2009 9:21 PM
    • Marked as answer by Nancy Shao Friday, December 4, 2009 8:44 AM
    Friday, November 27, 2009 9:21 PM
  • Hello,

    Then you don't want the Add Reference dialog at all, you want a selected dll to be added as reference to a project that your wizard creates.

    So, the wizard must show the Open common dialog of Windows (not the Add Reference dialog of Visual Studio) to select the dll from the file system and then you will have the full path to the dll file. Then, create the project without the reference and once created, read the .csproj and add the lines that Visual Studio uses to include references in a project, and save the new .csproj file. Since the project is not opened in Visual Studio, this will work fine and it is the easiest and faster approach (but VS-version specific). Once the wizard is done, when the user (or the wizard) opens the project in VS, the reference will be there.

    If that approach doesn't meet your needs post again to use the automation (EnvDTE) approach.


    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about VS extensibility: http://msmvps.com/blogs/carlosq/
    • Marked as answer by Nancy Shao Friday, December 4, 2009 8:44 AM
    Thursday, December 3, 2009 9:33 AM

All replies

  • See:

    How to display an assembly in the "Add Reference" dialog box
    http://support.microsoft.com/kb/306149
    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about VS extensibility: http://msmvps.com/blogs/carlosq/
    • Proposed as answer by Carlos J. Quintero Friday, November 27, 2009 9:21 PM
    • Marked as answer by Nancy Shao Friday, December 4, 2009 8:44 AM
    Friday, November 27, 2009 9:21 PM
  • Hi Carlos,
    I want the dll to be displayed to the Add Reference dialog box dynamically.I have created a setup project wherein I select a custom project template,upon which a custom wizard pops up.I select the dll to be added from this custom wizard(checkbox with the dll name) which should dynamically add the dll to the Add Reference dialog box when I am done with the wizard. i.e my new application should now contain the dll which I have selected in my wizard

    The link which you have given shows how can we manually create a key for the dll to get added to the Add Reference dialog box.

    How can I achieve the same in my scenario.

    Thanks in advance
    Monday, November 30, 2009 3:41 AM
  • I don't fully understand your explanation because of:

    "add the dll to the Add Reference dialog box when I am done with the wizard. i.e my new application should now contain the dl"

    I mean, adding a dll to appear in the Add Reference dialog doesn't make your application to contain it. So:

    - If you want the dll selected in the setup wizard to appear in the Add Reference dialog, your setup has to add programmatically the registry entry as explained in the article that I provided.

    - If you want to add a reference to a project programmatically, you don't need the Add Reference dialog at all, you can use the automation model (EnvDTE and VSLangProj). You get the root object EnvDTE.DTE, you get the project (DTE.Solution.Projects.Item(x)), you convert the EnvDTE.Project.Object to VSLangProj.VSProject and you use the VSProject.References.Add method. See the related article about references:

    HOWTO: Getting information specific to VB.NET and C# projects from an add-in or macro
    http://www.mztools.com/articles/2005/MZ2005011.aspx
    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about VS extensibility: http://msmvps.com/blogs/carlosq/
    Wednesday, December 2, 2009 10:02 AM
  • Hi Carlos,
    Apologize for not been clear in mentioning my requirement.

    The requirement is that I will select the dll from the custom wizard as mentioned above .I want this dll to be added as a reference to the newly created project.I went through the link which you have provided but was not clear with it.Can you provide any sample code (C#) for the same.Also the application which I am creating is a mobile application.

    Thanks
    Wednesday, December 2, 2009 1:15 PM
  • Hello,

    Then you don't want the Add Reference dialog at all, you want a selected dll to be added as reference to a project that your wizard creates.

    So, the wizard must show the Open common dialog of Windows (not the Add Reference dialog of Visual Studio) to select the dll from the file system and then you will have the full path to the dll file. Then, create the project without the reference and once created, read the .csproj and add the lines that Visual Studio uses to include references in a project, and save the new .csproj file. Since the project is not opened in Visual Studio, this will work fine and it is the easiest and faster approach (but VS-version specific). Once the wizard is done, when the user (or the wizard) opens the project in VS, the reference will be there.

    If that approach doesn't meet your needs post again to use the automation (EnvDTE) approach.


    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about VS extensibility: http://msmvps.com/blogs/carlosq/
    • Marked as answer by Nancy Shao Friday, December 4, 2009 8:44 AM
    Thursday, December 3, 2009 9:33 AM