C# 找不到与方案 net.tcp 匹配的基地址
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1793119/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not find a base address that matches scheme net.tcp
提问by Peter
I have moved my file transfer service from basicHttpBinding to netTcpBinding as I am trying to set up a duplex mode channel. I have also started my net.tcp port sharing service.
在尝试设置双工模式通道时,我已将文件传输服务从 basicHttpBinding 移至 netTcpBinding。我还启动了我的 net.tcp 端口共享服务。
I am currently in dev and am self hosting on an xp box until we move the app to a dev server. so, for now, I do not have access to IIS.
我目前在开发中,并且在我们将应用程序移动到开发服务器之前我在 xp 机器上自我托管。所以,目前,我无权访问 IIS。
After configuring my service as such:
在这样配置我的服务后:
<service behaviorConfiguration="transferServiceBehavior" name="API.FileTransfer.FileTransferService">
<endpoint name="MyFileTransferEP"
address = ""
binding = "netTcpBinding"
bindingConfiguration="MyFileTransferNetTcpEP"
behaviorConfiguration="NetTcpEPBehavior"
contract="API.FileTransfer.IFileTransferService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8001/project/filetransfer.svc" />
</baseAddresses>
</host>
</service>
And, my binding as such:
而且,我的绑定是这样的:
<netTcpBinding>
<binding name="MyFileTransferNetTcpEP"
hostNameComparisonMode="StrongWildcard"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
maxReceivedMessageSize="2147483647"
transferMode="Streamed"
portSharingEnabled="true">
<security mode="None">
<transport clientCredentialType="None" />
<message clientCredentialType="None" />
</security>
</binding>
</netTcpBinding>
I get the folloing error when I right and browser to the SVC file:
当我正确浏览 SVC 文件时,出现以下错误:
Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].
找不到与绑定 NetTcpBinding 的端点的方案 net.tcp 匹配的基地址。注册的基地址方案是 [http]。
The reading online suggests that, in order to fix this problem, i needed to add the net.tcp binding to the binding of the application in IIS. But, what do I do if I am self hosting and do not have access to IIS?? By the way, if you are reading this and "do" have IIS, do the following: Right click the virtual directory/application in IIS -> Manage application -> Advanced settings. And, in the Enabled Protocols part, add net.tcp.
网上的阅读建议,为了解决这个问题,我需要将net.tcp绑定添加到IIS中应用程序的绑定中。但是,如果我是自托管并且无法访问 IIS,我该怎么办??顺便说一句,如果您正在阅读本文并且“确实”拥有 IIS,请执行以下操作:右键单击 IIS 中的虚拟目录/应用程序 -> 管理应用程序 -> 高级设置。并且,在 Enabled Protocols 部分,添加 net.tcp。
Any ideas?
有任何想法吗?
UPDATE: I thought I had it working but it's still not working. Here is what I have now: I am still getting the "could not find base address that matches scheme net.tcp" error. I have changed all my base addresses to reflect your suggestion. Here is what I have now:
更新:我以为我可以正常工作,但仍然无法正常工作。这是我现在所拥有的:我仍然收到“找不到与方案 net.tcp 匹配的基地址”错误。我已经更改了我所有的基地址以反映您的建议。这是我现在所拥有的:
<service behaviorConfiguration="transferServiceBehavior" name="API.FileTransfer.FileTransferService">
<endpoint name="MyJSONFileTransferEP"
address="json"
binding="webHttpBinding"
bindingConfiguration="jsonWeb"
behaviorConfiguration="WebHttpEPBehavior"
contract="API.FileTransfer.IJSONFileTransferService" />
<endpoint name="MyPOXFileTransferEP"
address="pox"
behaviorConfiguration="WebHttpEPBehavior"
binding="webHttpBinding"
bindingConfiguration="poxWeb"
contract="API.FileTransfer.IPOXFileTransferService" />
<endpoint name="MySOAPFileTransferEP"
address="filetransfer"
binding="netTcpBinding"
bindingConfiguration="netTcpWeb"
behaviorConfiguration="NetTcpEPBehavior"
contract="API.FileTransfer.ISOAPFileTransferService" />
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:2544/filetransfer/" />
</baseAddresses>
</host>
</service>
I have tried this with both "net.tcp://localhost:2544" & "net.tcp://localhost:8001". Do I need to add (allow) something in my firewall settings? Any other suggestions?
我用“net.tcp://localhost:2544”和“net.tcp://localhost:8001”都试过了。我是否需要在防火墙设置中添加(允许)某些内容?还有其他建议吗?
Here is my filetransferservice's mexTcpBinding in my App.config file:
这是我的 App.config 文件中的文件传输服务的 mexTcpBinding:
<endpoint address="net.tcp://localhost:2544/filetransfer/mex"
binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange"
name="filetransfermex">
<identity>
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
I am still unable to reference my FileTransferServiceClient in my web app.
我仍然无法在我的 Web 应用程序中引用我的 FileTransferServiceClient。
Thanks again.
再次感谢。
采纳答案by marc_s
You need to define just the base address(not the wholeaddress) for your service, and then the rest in the service endpoint. The address you have with the filetransfer.svc
file at the end is not a valid base address (it's a file address, really)
您只需要为您的服务定义基地址(而不是整个地址),然后在服务端点中定义其余地址。你与地址filetransfer.svc
在最后文件不是一个有效的基本地址(这是一个文件地址,真)
<service behaviorConfiguration="transferServiceBehavior"
name="API.FileTransfer.FileTransferService">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8001/project/" />
</baseAddresses>
</host>
<endpoint name="MyFileTransferEP"
address = "filetransfer"
binding = "netTcpBinding"
bindingConfiguration="MyFileTransferNetTcpEP"
behaviorConfiguration="NetTcpEPBehavior"
contract="API.FileTransfer.IFileTransferService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
With this, and using self-hosting, your service would be available at the complete address:
有了这个,并使用自托管,您的服务将在完整地址处可用:
net.tcp://localhost:8001/project/filetransfer
Since this is net.tcp and you're self-hosting, there's no need for a svc file at all.
由于这是 net.tcp 并且您是自托管的,因此根本不需要 svc 文件。
UPDATE:if you want to be able to get metadata on your net.TCP base address, you'll need to expose a net.Tcp MEX endpoint like this inside your <service>
section:
更新:如果您希望能够在 net.TCP 基址上获取元数据,则需要在您的<service>
部分中公开这样的 net.Tcp MEX 端点:
<endpoint name="NetTcpMEX"
address="netTcpMex"
binding="mexTcpBinding"
contract="IMetadataExchange" />
回答by Mukul Narad
Please install "Non-Http activation" window component from Control Panel -> Programs -> Turn Window On or off -> Features -> Add features -> .net framework .* features -> Wcf activation -> Non-Http Activation.
请从控制面板 -> 程序 -> 打开或关闭窗口 -> 功能 -> 添加功能 -> .net 框架安装“非 Http 激活”窗口组件。* 功能 -> Wcf 激活 -> 非 Http 激活。
回答by Amir Hussein Samiani
Error (WCF): Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].
错误 (WCF): 找不到与绑定 NetTcpBinding 的终结点的方案 net.tcp 匹配的基地址。注册的基地址方案是 [http]。
Step 1: Note WAS (Windows Process Activation Service) or non-http protocol support, is only supported by following platforms: ? Windows Vista ? Windows 7 ? Windows Server 2008
第 1 步:注意 WAS(Windows 进程激活服务)或非 http 协议支持,仅受以下平台支持: ? 视窗 ? Windows 7的 ?视窗服务器 2008
- Go to Turn Windows features on or off
- Go to Microsoft .NET Framework 3.5
- Check Windows Communication Foundation HTTP Activation
- Check Windows Communication Foundation Non-HTTP Activation
- 转到打开或关闭 Windows 功能
- 转至 Microsoft .NET Framework 3.5
- 检查 Windows Communication Foundation HTTP 激活
- 检查 Windows Communication Foundation 非 HTTP 激活
Step 2: IIS > WCF Host Web Site > Manage Application > advanced Settings > Enabled Protocols > Set the value to HTTP,NET.TCP
步骤 2:IIS > WCF 主机网站 > 管理应用程序 > 高级设置 > 启用协议 > 将值设置为 HTTP,NET.TCP
回答by Albert
I had the same problem (Environment: Win7/IIS7.5 .NET4) and I solved it by configuring the binding through appcmd.exe, available form the directory "c:\Windows\System32\inetsrv"
我遇到了同样的问题(环境:Win7/IIS7.5 .NET4),我通过通过 appcmd.exe 配置绑定解决了它,可从目录“c:\Windows\System32\inetsrv”获得
"appcmd.exe set pp "WebsiteName/applicationName" /enabledProtocols:http,net.tcp"
"appcmd.exe 设置 pp "WebsiteName/applicationName" /enabledProtocols:http,net.tcp"
note: IIS configuration is hierarchical and consequently we should change config at the lowest possible level to avoid unwanted changes/security issues on other applications.
注意:IIS 配置是分层的,因此我们应该在尽可能低的级别更改配置,以避免其他应用程序发生不必要的更改/安全问题。
The following links may help: http://msdn.microsoft.com/en-us/library/ms788757.aspxhttp://support.microsoft.com/kb/2803161
以下链接可能会有所帮助:http: //msdn.microsoft.com/en-us/library/ms788757.aspx http://support.microsoft.com/kb/2803161
Hope this help Albert
希望这有助于阿尔伯特
回答by dotnetmem
Space in "Enabled Protocols" entry in IIS => Select virtual Directory/application => advanced settings => Enabled Protocols. e.g. http, net.tcp. (Space between protocol text
IIS 中“启用的协议”条目中的空间 => 选择虚拟目录/应用程序 => 高级设置 => 启用的协议。例如http、net.tcp。(协议文本之间的空格
This should be http,net.tcp(ie. no space between the protocol text)
这应该是http,net.tcp(即协议文本之间没有空格)
回答by granadaCoder
For future readers.
对于未来的读者。
Make sure you notusing IIS-Express.
确保您没有使用 IIS-Express。
This was my "gotcha".
这是我的“陷阱”。
Reference:
参考:
http://www.iis.net/learn/extensions/introduction-to-iis-express/iis-express-faq
http://www.iis.net/learn/extensions/introduction-to-iis-express/iis-express-faq
Q: Does IIS Express support non-HTTP protocols such as net.tcp or MSMQ?
A: No. IIS Express only supports HTTP and HTTPS as its protocol.
This is a property under Visual Studio and the web.csproj (or similar) Properties and the "Web" left-tab. There is a checkbox called "Use IIS Express". Uncheck that.
这是 Visual Studio 和 web.csproj(或类似)属性和“Web”左侧选项卡下的属性。有一个名为“使用 IIS Express”的复选框。取消选中。
After you do that, you'll still have to go to IIS(7) and "http,net.tcp" for "Enabled Protocols" (as described in other answers here)
执行此操作后,您仍然需要转到 IIS(7) 和“http,net.tcp”以获取“启用的协议”(如此处的其他答案中所述)
Also, if you're getting the named pipe specific error.
此外,如果您收到命名管道特定的错误。
Could not find a base address that matches scheme net.pipe for the endpoint with binding NetNamedPipeBinding.
找不到与绑定NetNamedPipeBinding的端点的方案 net.pipe 匹配的基地址。
Then you need to add "net.pipe" to the list.
然后您需要将“net.pipe”添加到列表中。
Example:
例子:
http,net.tcp,net.pipe
http,net.tcp,net.pipe
Also see the below for the named pipe specific error.
另请参阅下面的命名管道特定错误。
Configure WCF as Named Pipe hosted on IIS7
ALSO: Check these corresponding windows services (named pipes or tcp or both)
还:检查这些相应的 Windows 服务(命名管道或 tcp 或两者)
(named pipes windows service)
(命名管道窗口服务)
NetPipeActivator
Net.Pipe Listener Adapter
Receives activation requests over the net.pipe protocol and passes them to the Windows Process Activation Service.
(tcp windows service)
(tcp windows服务)
NetTcpActivator
Net.Tcp Listener Adapter
Receives activation requests over the net.tcp protocol and passes them to the Windows Process Activation Service.
回答by Moumit
After going through a lots of solution .. i found the final solutionin this blog.. however i am going to explain the whole procedure here .. you need to follow the below steps ..
在经历了很多解决方案之后..我在这个博客中找到了最终的解决方案..但是我将在这里解释整个过程..你需要按照以下步骤..
Step1:(Windows Process Activation Service) or non-http protocol support, is only supported by following platforms: ? Windows Vista ? Windows 7 ? Windows Server 2008
Step1:(Windows Process Activation Service)或非http协议支持,仅以下平台支持: ? 视窗 ? Windows 7的 ?视窗服务器 2008
- Go to Turn Windows features on or off
- Go to Microsoft .NET Framework 3.5
- Check Windows Communication Foundation HTTP Activation
- Check Windows Communication Foundation Non-HTTP Activation
- 转到打开或关闭 Windows 功能
- 转至 Microsoft .NET Framework 3.5
- 检查 Windows Communication Foundation HTTP 激活
- 检查 Windows Communication Foundation 非 HTTP 激活
Step 2:IIS > WCF Host Web Site > Manage Application > advanced Settings > Enabled Protocols > Set the value to http,net.tcp
第 2 步:IIS > WCF 主机网站 > 管理应用程序 > 高级设置 > 启用协议 > 将值设置为http,net.tcp
check if your problem solved after step2 completion..if not then follow below step
检查您的问题是否在第 2 步完成后解决了..如果没有,请按照以下步骤操作
Step 3:In an administrator-level Command Prompt window
, run the following command.
第 3 步:在 中administrator-level Command Prompt window
,运行以下命令。
%windir%\system32\inetsrv\appcmd.exe set site "Default Web Site" -+bindings.[protocol='net.tcp',bindingInformation='8082:*']
Restart the IISonce or you could get Failed to map the path '/'
exception now
重新启动 IIS一次,否则您Failed to map the path '/'
现在可能会遇到异常
Your application in advance setting will looks like below now
您的应用程序预先设置现在将如下所示
回答by Benj
For Windows 10
Step 1: Go to Turn Windows features on and off > .Net Framework 4.6 Advanced Services > WCF Services > TCP Activation
对于 Windows 10
步骤 1:转到打开和关闭 Windows 功能 > .Net Framework 4.6 高级服务 > WCF 服务 > TCP 激活
Step 2: IIS > WCF Host Web Site > Manage Application > advanced Settings > Enabled Protocols > Set the value to net.tcp,http
第 2 步:IIS > WCF 主机网站 > 管理应用程序 > 高级设置 > 启用协议 > 将值设置为 net.tcp,http
Step 3: Open command console with administrative rights > type iisreset
第 3 步:使用管理权限打开命令控制台 > 键入 iisreset
回答by Paul Cenan
I had the same error on a Windows 7 and fixed it by opening IIS, right click on the website that holds your application and select 'Edit Bindings...'. I added here the net.tcp binding and the problem was solved.
我在 Windows 7 上遇到了同样的错误,并通过打开 IIS,右键单击包含您的应用程序的网站并选择“编辑绑定...”来修复它。我在这里添加了 net.tcp 绑定,问题就解决了。