使用 UAC 调试 WCF NetTCP 服务

发布于 2024-09-26 08:31:33 字数 1610 浏览 2 评论 0原文

我配置了一组 NetTCP 服务,它们在 Windows 服务下运行以进行生产,但我使用控制台应用程序来启动它们以进行调试。在 Windows Vista 中,我完全禁用了 UAC,因为它很烦人,但是我尝试在 7 中启用它,因为它可以完成我想要的所有操作,同时非常安静且不烦人。

我遇到的问题是,当在“标准”模式下运行 VS 时(即不使用以管理员身份运行),服务不会启动,因为它说:

“服务端点无法侦听 URI 'net.tcp:/ /localhost:60000/[ServiceName]',因为访问被拒绝。请验证当前用户是否已在 SMSvcHost.exe.config 的相应 allowedAccounts 部分中获得访问权限。”

经过一番研究后,我找到了这个文件,并使用我的用户帐户的 SID 对其进行了修改。配置如下所示:

<?xml version="1.0" encoding="utf-8"?><configuration>
<runtime>
    <gcConcurrent enabled="false" />
    <generatePublisherEvidence enabled="false" />
</runtime>

<system.serviceModel.activation>
    <net.tcp listenBacklog="10" maxPendingConnections="100" maxPendingAccepts="2" receiveTimeout="00:00:10" teredoEnabled="false">
        <allowAccounts>
            <add securityIdentifier="S-1-5-21-XXXXXXX"/>
        </allowAccounts>
    </net.tcp>
    <net.pipe maxPendingConnections="100" maxPendingAccepts="2" receiveTimeout="00:00:10">
        <allowAccounts>
            <add securityIdentifier="S-1-5-21-XXXXXXX"/>
        </allowAccounts>
    </net.pipe>
    <diagnostics performanceCountersEnabled="true" />
</system.serviceModel.activation></configuration>

SID 来自 Sysinternals 套件中打包的工具,并针对 ADSI Edit 进行了验证,因此我知道它是正确的。重新启动后,服务仍然不会启动,我试图避免强制它在管理模式下运行,因为这样你就不能再双击解决方案或项目文件了,这相当令人恼火。

有人有什么想法吗? SMSvcHost.exe.config 文件来自“C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation”,即使我运行的是 x64,该应用程序也是在 x86 模式下编译的。我不确定这是否是我的麻烦所在?

I have a set of NetTCP services configured that run under a Windows service for production but I use a console app to spin them up for debugging purposes. With Windows Vista I disabled UAC outright because it was annoying, however I'm trying to leave it enabled with 7 because it does everything I want while being very quiet and not naggy.

The issue I ran into is when running VS in "standard" mode (i.e. not using run as administrator) the services won't spin up because it says this:

"The service endpoint failed to listen on the URI 'net.tcp://localhost:60000/[ServiceName]' because access was denied. Verify that the current user is granted access in the appropriate allowedAccounts section of SMSvcHost.exe.config."

After a bit of research I was able to find this file and modify it with the SID for my user account. The config looks like this:

<?xml version="1.0" encoding="utf-8"?><configuration>
<runtime>
    <gcConcurrent enabled="false" />
    <generatePublisherEvidence enabled="false" />
</runtime>

<system.serviceModel.activation>
    <net.tcp listenBacklog="10" maxPendingConnections="100" maxPendingAccepts="2" receiveTimeout="00:00:10" teredoEnabled="false">
        <allowAccounts>
            <add securityIdentifier="S-1-5-21-XXXXXXX"/>
        </allowAccounts>
    </net.tcp>
    <net.pipe maxPendingConnections="100" maxPendingAccepts="2" receiveTimeout="00:00:10">
        <allowAccounts>
            <add securityIdentifier="S-1-5-21-XXXXXXX"/>
        </allowAccounts>
    </net.pipe>
    <diagnostics performanceCountersEnabled="true" />
</system.serviceModel.activation></configuration>

The SID came from the tool packaged in the Sysinternals suite and was validated against ADSI Edit so I know it's correct. After a reboot the services still won't spin up though and I'm trying to avoid forcing it to run in administrative mode because then you can't double-click on solution or project files anymore which is rather irritating.

Anyone have any ideas? The SMSvcHost.exe.config file came from "C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation" and even though I'm running x64 the app is compiled in x86 mode. I'm not sure if that is where my trouble lies?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纵性 2024-10-03 08:31:33

要找到“正确”的配置文件位置,请执行以下操作:
在任务管理器的服务选项卡中找到 NetTcpPortSharing。
单击上下文菜单中的“转到处理”。
单击打开文件位置。

附:
在我的带有 .NET 4 的 Windows 2008 R2 x64 上,位置是 C:\Windows\Microsoft.NET\Framework64\v4.0.30319

To find "right" configuration file location do the following:
Locate NetTcpPortSharing in serivce tab in Task Manager.
Click Go to process in context menu.
Click Open file location.

ps.
on my Windows 2008 R2 x64 with .NET 4 location is C:\Windows\Microsoft.NET\Framework64\v4.0.30319

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文