Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Custom Wizard: Is it possible to add a dll reference to a project on creation from a custom wizard?

Custom Wizard: Is it possible to add a dll reference to a project on creation from a custom wizard?

Scheduled Pinned Locked Moved C#
csharpvisual-studiowpfquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jehammon
    wrote on last edited by
    #1

    Hello, I was wondering if anyone could tell me if what I'm trying to accomplish is possible. I am using C# in VS 2008. I have two project templates and another template which links the two projects and calls their templates. The first project is a user control and the second is a test app that needs to reference the user control. I also have a custom wizard that is called from the template. After the projects are created the wizard compiles the user control and gets the path to its dll. I then need to add a reference to the user control from the dll path to my test app. It is not possible for me to add the reference before this as I don't know what the name of the dll will be until the user creates the new user control project giving it whatever name they want. Does anyone know how this could be done?

    R 1 Reply Last reply
    0
    • J Jehammon

      Hello, I was wondering if anyone could tell me if what I'm trying to accomplish is possible. I am using C# in VS 2008. I have two project templates and another template which links the two projects and calls their templates. The first project is a user control and the second is a test app that needs to reference the user control. I also have a custom wizard that is called from the template. After the projects are created the wizard compiles the user control and gets the path to its dll. I then need to add a reference to the user control from the dll path to my test app. It is not possible for me to add the reference before this as I don't know what the name of the dll will be until the user creates the new user control project giving it whatever name they want. Does anyone know how this could be done?

      R Offline
      R Offline
      Rolando CC
      wrote on last edited by
      #2

      Maybe Reflection is what you want, google it.

      J 1 Reply Last reply
      0
      • R Rolando CC

        Maybe Reflection is what you want, google it.

        J Offline
        J Offline
        Jehammon
        wrote on last edited by
        #3

        Thank you for the reply. I've been googling for about a week and tried many different things including reflection. I tried Assembly.LoadFrom(dllPath) in the wizard but that just adds the reference to the project that the code is in. I checked out reflection where you can get the type and instantiate an object of that type and call methods from it, but that object is already created. I don't want a new one. When I set an assembly variable in the wizard equal to the assembly of the object needing the reference, the LoadFrom function doesn't exist.

        J 1 Reply Last reply
        0
        • J Jehammon

          Thank you for the reply. I've been googling for about a week and tried many different things including reflection. I tried Assembly.LoadFrom(dllPath) in the wizard but that just adds the reference to the project that the code is in. I checked out reflection where you can get the type and instantiate an object of that type and call methods from it, but that object is already created. I don't want a new one. When I set an assembly variable in the wizard equal to the assembly of the object needing the reference, the LoadFrom function doesn't exist.

          J Offline
          J Offline
          Jehammon
          wrote on last edited by
          #4

          I found the answer on another forum. // Provide the information about project1 to project2

          VSProject projectWithReferences = project2.Object as VSProject;
          if (projectWithReferences != null)
          {
          // add a project reference... this takes care of dependencies and will enable the msbuild targets to know how to retrieve the outputs
          Reference reference = projectWithReferences.References.AddProject(project1);
          }

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups