【问题标题】:Performance and diagnostics with "Cannot start service... A Windows Service must first be intalled (using installutil.exe)..."“无法启动服务...必须首先安装 Windows 服务(使用 installutil.exe)...”的性能和诊断
【发布时间】:2014-08-11 17:56:15
【问题描述】:

目前,我正在尝试使用 Visual Studio 2013 中的新“性能和诊断”功能分析我正在开发的 Windows 服务(请参阅http://blogs.msdn.com/b/visualstudioalm/archive/2013/07/12/performance-and-diagnostics-hub-in-visual-studio-2013.aspx)。当我尝试分析服务时,我收到以下错误消息:

Cannot start service from the command line or a debugger.  A Windows Service must first be intalled (using installutil.exe) and then started with the ServerExplorer, Windows Services Administrative Tool or the NET START command.

通常在调试服务时,它工作正常,因为我在 Program.cs 中有以下代码:

    private static MySvc _serviceInstance;
    private static readonly List<ServiceBase> _servicesToRun =
        new List<ServiceBase>();

    static void Main(string[] args)
    {
        _servicesToRun.Add(_serviceInstance);

        if (Environment.UserInteractive)
        {
            _servicesToRun.ToArray().LoadServices();
        }
        else
        {
            ServiceBase.Run(_servicesToRun.ToArray());
        }
    }

    static Program()
    {
        _serviceInstance = new MySvc();
    } 

另外,如果我尝试附加到正在运行的应用程序,在出现的对话框中它不会显示任何正在执行的进程,并且当我将服务的名称放在那里时,它找不到它。有没有人有什么建议? TIA。

更新:这是我尝试附加到进程时得到的结果。为什么“性能和诊断”看不到我的计算机上运行的任何进程?为什么它只会连接到 Windows Store 应用程序而不是所有 exe?请看这张图片:

【问题讨论】:

  • 尝试用VS性能工具附加到服务进程

标签: c# windows performance service diagnostics


【解决方案1】:

我解决问题的方法是复制所有源代码并进行少量修改以使所有内容都在控制台应用程序中运行,然后选择调试->性能和诊断并使用“更改目标”运行控制台应用程序-> "启动和可执行文件 (.exe)"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-20
    • 2010-12-28
    相关资源
    最近更新 更多