Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

Visual Studio 2012 closes my new solution

$
0
0

Hi

I am creating a VS2012 wizard to create a C# solution, using a similar approach tothis article, except that I have a New Project template that fires my wizard.

This is my IWizard implementation:

    public class ExtensionWizard : IWizard
    {
        #region Properties

        private DTE2 dte;
        private Solution4 solution;
        private string solutionPath = string.Empty;
        public static Dictionary<string, string> GlobalDictionary = new Dictionary<string, string>();

        #endregion

        public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            dte = automationObject as DTE2;
            Debug.Assert(dte != null, "dte != null");
            solution = dte.Solution as Solution4;
            Debug.Assert(solution != null, "solution!= null");

            solutionPath = replacementsDictionary["$destinationdirectory$"];
            if (!Directory.Exists(solutionPath))
            {
                Directory.CreateDirectory(solutionPath);
            }

            var myClass = solution.GetProjectTemplate("Class Library", "CSharp");
            solution.AddFromTemplate(myClass, solutionPath, "Hello", false);
        }

        public void ProjectFinishedGenerating(Project project)
        {
            throw new NotImplementedException();
        }

        public void ProjectItemFinishedGenerating(ProjectItem projectItem)
        {
            throw new NotImplementedException();
        }

        public bool ShouldAddProjectItem(string filePath)
        {
            throw new NotImplementedException();
        }

        public void BeforeOpeningFile(ProjectItem projectItem)
        {
            throw new NotImplementedException();
        }

        public void RunFinished()
        {
            throw new NotImplementedException();
        }
    }

When the wizard is invoked, the RunStarted() method is called and runs to the end without problems.

After exiting RunStarted(), Visual Studio immediately wants to close the solution without calling any other methods such as ProjectFinishedGenerating(), or RunFinished().  The SaveChanges dialog is shown and if I select Yes, or No, the solution is closed.  If I select Cancel, the solution remains open in VS2012 and I can examine the Solution Explorer to confirm that it is created correctly.

This is not the same behavior when I create a standard C# project such as ClassLibrary, so what is going on and how do I make my wizard behave the same way?


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>