gpt4 book ai didi

windows - WCF 作为服务托管

转载 作者:可可西里 更新时间:2023-11-01 10:50:24 26 4
gpt4 key购买 nike

我有一个作为窗口服务托管的 VB.NET WCF 服务。我能够创建一个安装包,将服务安装到我的机器上,并从管理工具中的服务手动启动该服务。

现在,当我尝试在我的测试控制台应用程序(地址:http://localhost:8080/)中引用该服务时,出现以下错误:

There was an error downloading 'http://localhost:8080'.`

Unable to connect to the remote server No connection could be made because the target machine actively refused it 127.0.0.1:8080`

Metadata contains a reference that cannot be resolved: 'http://localhost:8080/'. Could not connect to http://localhost:8080/. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8080. Unable to connect to the remote server No connection could be made because the target machine actively refused it 127.0.0.1:8080 If the service is defined in the current solution, try building the solution and adding the service reference again.

不确定我能做些什么。有什么想法吗???

谢谢,杰森。

这是我服务中 app.config 的代码:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
</sharedListeners>
</system.diagnostics>

<system.serviceModel>
<services>
<service name="ExStreamWCF.Service1"
behaviorConfiguration="ExStreamWCF.Service1Behavior">
<!-- Service Endpoints -->
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8080/Design_Time_Addresses/JasonsService/Service/" />
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" contract="ExStreamWCF.IService1">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ExStreamWCF.Service1Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>

如果有人需要我提供更多信息,请告诉我!

最佳答案

不确定这是否真的是个问题 - 但在生产服务器上,我绝不会使用 localhost 作为我的基址。

那么你能否尝试改变:

<service name="ExStreamWCF.Service1" 
behaviorConfiguration="ExStreamWCF.Service1Behavior">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8080/Design_Time_Addresses/JasonsService/Service/" />
</baseAddresses>
</host>

<service name="ExStreamWCF.Service1" 
behaviorConfiguration="ExStreamWCF.Service1Behavior">
<host>
<baseAddresses>
<add baseAddress = "http://YourServerName:8080/Design_Time_Addresses/JasonsService/Service/" />
</baseAddresses>
</host>

调用服务时这有什么不同吗??

关于windows - WCF 作为服务托管,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5955899/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com