Visual Studio 2012关闭了我的新解决方案 [英] Visual Studio 2012 closes my new solution

查看:188
本文介绍了Visual Studio 2012关闭了我的新解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个VS2012向导来创建C#解决方案,使用类似的方法 本文,不同之处在于我有一个新项目模板可以触发我的向导.

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

这是我的IWizard实现:

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();
        }
    }

调用向导时,将调用RunStarted()方法并运行到最后而不会出现问题.

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

退出RunStarted()后,Visual Studio立即希望关闭解决方案而不调用任何其他方法,例如ProjectFinishedGenerating()或RunFinished().将显示保存更改"对话框,如果我选择是"或否",则解决方案已关闭. 如果选择取消",则解决方案在VS2012中保持打开状态,我可以检查解决方案资源管理器以确认其创建正确.

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.

创建标准的C#项目(例如ClassLibrary)时,这是不同的行为,那么发生了什么以及如何使向导的行为相同?

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?

推荐答案

我正在尝试让熟悉此主题的人进一步研究此问题.可能会有一些时间延迟.感谢您的耐心.
 
感谢您的理解和支持.

I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.
 
Thank you for your understanding and support.

最好的问候


这篇关于Visual Studio 2012关闭了我的新解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆