【问题标题】:WCF Named Pipes and Azure Web RolesWCF 命名管道和 Azure Web 角色
【发布时间】:2012-07-17 22:24:45
【问题描述】:

为了这个,我已经用头撞墙太久了。

运行 Azure SDK 1.7 / Visual Studio 2010 Ultimate。我似乎无法在 IIS/WAS 托管的命名管道上运行 WCF 服务。在计算模拟器中连接到我的服务的任何尝试都会产生

在您的本地计算机上找不到管道端点“net.pipe://localhost/services/MyService.svc”

我打算发布我的代码,但结果发现这篇文章http://blogs.msdn.com/b/tomholl/archive/2011/06/28/hosting-services-with-was-and-iis-on-windows-azure.aspx 中的示例代码给了我完全相同的错误。所有代码都可以在该站点上找到。

据我所知,powershell 任务正在成功执行。 (好吧,好吧,我不得不在启动任务中将 ExecutionPolicy 从 Unrestricted 更改为 RemoteSigned,但之后它运行得很好。) NetPipeActivator 服务正在运行,当我调用 Get-WebApplication 时,我在协议中看到 net.pipe列表:

PS C:\> $WebRoleSite = (get-website "*webrole*").Name
PS C:\> Get-WebApplication -Site $WebRoleSite

Name             Application pool   Protocols    Physical Path
----             ----------------   ---------    -------------
WcfService1      4a16b147-f9ac-41d9 http,net.pip c:\Code\WasInAzure\WcfService1
                 -9543-0577da64fb9a e

还会发生什么?

【问题讨论】:

标签: wcf azure named-pipes


【解决方案1】:

我解决了。呸!

我的问题是我从根网站中托管我的 WCF 服务,而不是子应用程序。我必须在 powershell 脚本中添加以下行以在主网站上启用命名管道:

Set-ItemProperty "IIS:/Sites/$WebRoleSite" -Name EnabledProtocols 'http,net.pipe'

【讨论】:

    【解决方案2】:

    我在使用此示例代码时也遇到了这个错误。就我而言,我在尝试复制云服务时收到错误,但解决方案中的原始云服务项目没有。

    最终的关键区别在于 ServiceConfiguration.csfg file 中 ServiceConfiguration 元素的 osFamily 属性。

    在示例中,它设置为“2:”

    <ServiceConfiguration serviceName="WasInAzure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="2" osVersion="*" schemaVersion="2015-04.2.6">
    

    在较新的项目中,它设置为“4:”

    <ServiceConfiguration serviceName="WasInAzure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="4" osVersion="*" schemaVersion="2015-04.2.6">
    

    操作系统的更改破坏了 PowerShell 脚本。这是 RoleStart.ps1 的更新版本,它应该可以在 Server 2012 R2 (osFamily 4) 上运行:

    write-host "Begin RoleStart.ps1"
    import-module WebAdministration 
    
    # Starting the listener service 
    install-windowsfeature -name AS-Named-Pipes
    $listenerService = Get-WmiObject win32_service -filter "name='NetPipeActivator'"
    $listenerService.ChangeStartMode("Manual")
    $listenerService.StartService()
    
    # Enable net.pipe bindings
    $WebRoleSite = (Get-WebSite "*webrole*").Name
    Get-WebApplication -Site $WebRoleSite | Foreach-Object { $site = "IIS:/Sites/$WebRoleSite" + $_.path; Set-ItemProperty $site -Name enabledProtocols 'http,net.pipe'}
    New-ItemProperty "IIS:/Sites/$WebRoleSite" -name bindings -value @{protocol="net.pipe";bindingInformation="*"}
    
    write-host "End RoleStart.ps1"
    

    变更摘要:

    • 添加了install-windowsfeature -name AS-NamedPipes,因为 NetPipesActivator 服务不存在。

    • EnabledProtocols 更新为enabledProtocols。那个花了一些搜索。我终于找到了让我走上正确道路的a comment to a blog post

    【讨论】:

      猜你喜欢
      • 2011-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多