繁体   English   中英

通过“无法启动服务……必须首先安装Windows服务(使用installutil.exe)……”的性能和诊断。

[英]Performance and diagnostics with “Cannot start service… A Windows Service must first be intalled (using installutil.exe)…”

目前,我正在尝试使用Visual Studio 2013中的新“性能和诊断”功能来分析正在使用的Windows服务(请参阅http://blogs.msdn.com/b/visualstudioalm/archive/2013/07/ 12 /性能和诊断中心-视觉工作室-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文件? 请看这张图片:

在此处输入图片说明

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM