locked
EnvDTE.Soution related RRS feed

  • Question

  •  

      EnvDTE.Solution soln = System.Activator.CreateInstance(Type.GetTypeFromProgID("VisualStudio.Solution")) as EnvDTE.Solution;

       soln.DTE.MainWindow.Visible = true;

    EnvDTE80.Solution2 soln2 = soln as EnvDTE80.Solution2;

                 

                 

                   

                    if (solutiontype.Equals("Windows Forms Application"))

                    {

                        solutionfile = "WindowsApplication.zip";

                    }

                    else if (solutiontype.Equals("Console Application"))

                    {

                        solutionfile = "ConsoleApplication.zip";

                    }

                    string csTemplatePath = soln2.GetProjectTemplate(solutionfile, "CSharp");

                    prj = soln.AddFromTemplate(csTemplatePath, filespath, solutionname, true);

    i am using this code to create

    visual studio solution programatically .

    in prj variable i getting null.

    i want to use prj variable to add reference in the project so plz help me to find out why i getting null in prj variable.

    Monday, February 13, 2012 7:29 AM

Answers

  • Hi ShailiSha,
    As the code your provide is not completely, so I cannot reproduce this issue.
    But I think you should pay attention to the following points:
    1. Do you define your prj, like Project prj;
    2. How do you define "filespath" , solutionname, and so on.
    You can refer to this link http://msdn.microsoft.com/en-us/library/envdte._solution.addfromtemplate.aspx
    This link provides a sample demonstrate how to use the AddFromTemplate method.


    Best regards,
    Lucy


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by lucy-liu Monday, February 20, 2012 7:26 AM
    Tuesday, February 14, 2012 6:47 AM

All replies

  • Hi ShailiSha,
    As the code your provide is not completely, so I cannot reproduce this issue.
    But I think you should pay attention to the following points:
    1. Do you define your prj, like Project prj;
    2. How do you define "filespath" , solutionname, and so on.
    You can refer to this link http://msdn.microsoft.com/en-us/library/envdte._solution.addfromtemplate.aspx
    This link provides a sample demonstrate how to use the AddFromTemplate method.


    Best regards,
    Lucy


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by lucy-liu Monday, February 20, 2012 7:26 AM
    Tuesday, February 14, 2012 6:47 AM
  • Hi ShailiSha,
    I temporary make my last reply as answer. You can unmark it if they provide no help.
    Thank you for your understanding!

    Best regards,
    Lucy


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us

    Monday, February 20, 2012 7:26 AM