想了解无法从Windows服务连接到WCF服务的新动态吗?本文将为您提供详细的信息,我们还将为您解答关于无法从服务器获取最新更新,请稍后重试的相关问题,此外,我们还将为您介绍关于Azure函数无法访问
想了解无法从Windows服务连接到WCF服务的新动态吗?本文将为您提供详细的信息,我们还将为您解答关于无法从服务器获取最新更新,请稍后重试的相关问题,此外,我们还将为您介绍关于Azure函数无法访问内部Windows服务器中托管的WCF服务、c# – WCF服务托管在Windows服务运行比控制台应用程序慢10倍、c# – Windows服务托管TCP WCF服务、c# – 从另一个WCF服务中调用WCF服务时WCF内存泄漏的新知识。
本文目录一览:- 无法从Windows服务连接到WCF服务(无法从服务器获取最新更新,请稍后重试)
- Azure函数无法访问内部Windows服务器中托管的WCF服务
- c# – WCF服务托管在Windows服务运行比控制台应用程序慢10倍
- c# – Windows服务托管TCP WCF服务
- c# – 从另一个WCF服务中调用WCF服务时WCF内存泄漏
无法从Windows服务连接到WCF服务(无法从服务器获取最新更新,请稍后重试)
我有一个远程计算机上托pipe的WCF服务。 在我的本地机器上,我有一个WPF应用程序和一个Windows服务,我希望能够连接到WCF服务。 WPF应用程序连接和通信很好,但由于某种原因,Windows服务将无法连接。 他们两个的app.config文件是相同的,并且在两者中build立连接的代码是相同的。 有什么理由为什么Windows服务将无法连接?
这是我得到的exception:
套接字连接被中止。 这可能是由处理您的消息时出错或远程主机超出接收超时或基础networking资源问题引起的。 本地套接字超时为'00:01:14.9900000'。
奇怪的是,这个exception是在5秒之内抛出,而不是在超时设置为1:15之后抛出。
XP和Windows 7/8上的DateTime.Parse不同
如何在Windows(8.1)中将自定义应用程序注册为Web浏览器?
Windows从多图标文件中select错误的图标,并自我渲染以更正大小
插入位置/位置在任何应用程序内
在Windows上进行蓝牙开发
这里是app.config:
<?xml version="1.0"?> <configuration> <appSettings> <add key="ServiceIP" value="127.0.0.1"/> </appSettings> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <probing privatePath="lib" /> </assemblyBinding> </runtime> <system.serviceModel> <bindings> <netTcpBinding> <binding name="NetTcpBindingEndpoint" closeTimeout="00:01:00" openTimeout="00:00:10" receiveTimeout="00:10:00" sendTimeout="00:01:15" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNaMetableCharCount="16384" /> <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /> <security mode="Transport"> <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /> <message clientCredentialType="Windows" /> </security> </binding> </netTcpBinding> </bindings> <client> <endpoint address="net.tcp://localhost:8731/WCFService/" binding="netTcpBinding" bindingConfiguration="NetTcpBindingEndpoint" contract="WCFService.IWCFService" name="NetTcpBindingEndpoint"> <identity> <dns value="localhost" /> </identity> </endpoint> </client> </system.serviceModel> <system.diagnostics> <sources> <source name="System.ServiceModel" switchValue="information,ActivityTracing" propagateActivity="true"> <listeners> <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="Traces.svclog"/> </listeners> </source> </sources> </system.diagnostics> </configuration>
据我所知,跟踪似乎没有透露任何有用的信息。
使用BluetoothLEDevice.FromIdAsync连接到蓝牙设备会导致错误
C# – 追加文本文件
在VB.net中实现这样的工具提示?
在C#中使用Socket改进TCP转发器
.NET Framework Windows XP错误,Visual Studio Express
检查您的Windows服务正在运行的帐户。 由于您正在访问网络资源,因此您需要一个拥有足够权限访问它的域帐户(就像您登录的用户帐户那样)。
Azure函数无法访问内部Windows服务器中托管的WCF服务
您的web.config文件可能有问题。已将其配置为使用地址localhost。
也可能是您尚未为应用程序服务打开https。
c# – WCF服务托管在Windows服务运行比控制台应用程序慢10倍
调用WCF服务的开销非常快,但是LoadFile方法需要更长的时间.我尝试在启动过程中增加进程优先级
Process.GetCurrentProcess ().PriorityClass = ProcesspriorityClass.High;
无济于事我在Win7 64位桌面系统(6gb),2003 XP 32bit服务器(4gb)和2008 R2 32bit服务器(4bg)上运行此服务,结果类似.控制台和桌面应用程序在上述系统上大约1分钟内处理文件.该进程似乎没有内存限制并进入swapville.
Windows服务是否以某种方式进行限制?在IIS下运行WCF服务可以获得更好的结果吗?
编辑:我尝试从网站调用库目录,也比控制台或桌面应用程序长10倍.
更新:原来是Log4PostSharp.控制台和桌面应用程序在配置文件中没有任何痕迹的log4net,而网站和Windows服务却没有.有一个log4net TraceAppender默默地吃掉了宝贵的cpu周期.
解决方法
垃圾收集器有三种模式 – 工作站,服务器和并发.每个人以不同的方式行事,并针对不同类型的应用进行了优化.工作站模式是默认模式,并且是所有进程运行的,除非配置为使用别的东西.有关模式的更多信息可以找到here.
尝试明确地将垃圾回收器设置为使用服务器模式(它将仅对多处理器计算机有影响).为此,请将以下内容放在您的app.config文件中:
<configuration> <runtime> <gcServer enabled="true" /> </runtime> </configuration>
c# – Windows服务托管TCP WCF服务
我的目标是能够远程访问wcf服务,但我似乎甚至无法在本地访问它,除非客户端是在同一客户端内创建的.是否有任何指南,教程或有用的提示,任何人都可以让我让这个工作?
更新:
似乎即使Windows服务正在运行,WCF服务似乎也没有监听任何端口.这表明它没有运行.这也解释了为什么每个人都认为我没有运行该服务.我曾经假设,因为Windows服务正在运行并且同一个解决方案客户端工作,所以WCF服务也正常运行.事实证明,每当我运行相同的解决方案客户端时,Visual Studio就会启动WCF服务.
那么,为什么Windows服务不启动WCF服务呢?有任何想法吗?
解决方法
Windows服务假设启动WCF服务,但它实际上是尝试再次启动,因为两个服务具有相同的名称.
myServiceHost = new ServiceHost(typeof(Service1));
要解决此问题,您可以在Windows服务中引用时重命名其中一个服务或完全限定WCF服务.
myServiceHost = new ServiceHost(typeof(WcfServiceLibrary1.Service1));
有趣的是,提供的代码看起来仍然有效,因为Visual Studio足够聪明,可以注意到WCF服务没有运行,它在幕后启动实例.
修复这是一个简单的错误,但由于Visual Studio隐藏了我的问题,我认为如果没有Espen Burud的帮助我就不会找到它.
c# – 从另一个WCF服务中调用WCF服务时WCF内存泄漏
在下面的示例中,我有两个服务A和B.当我在服务A上调用DoWork方法时,它又调用服务B的DoWork方法.
在下面的示例中,我每次都创建一个新的ChannelFactory,使用它打开一个通道,调用DoWork,然后在最后处理通道和工厂.这样,进程就会开始泄漏内存.
如果我设置其中一个或两个调用,每次重复使用相同的ChannelFactory(注释并取消注释示例中标记的行),泄漏就会停止.
如果我每次调用服务A时都继续创建一个新的ChannelFactory,但是空白了ServiceA的DoWork方法(因此它不会调用ServiceB),则不会发生泄漏.
我正在运行针对.NET 3.5的程序.奇怪的是,如果我切换到.NET 4,4.5或4.5.1,该过程会更快地泄漏内存.
任何人都可以理解为什么会这样,也许可以解决它(或至少解决它)?
示例代码如下:
using System; using System.ServiceModel; namespace memoryleak { internal class Program { private static void Main() { using (var hostA = new ServiceHost(new ServiceA(),new Uri("net.pipe://localhost"))) using (var hostB = new ServiceHost(new ServiceB(),new Uri("net.pipe://localhost"))) { hostA.AddServiceEndpoint(typeof (ContractA),new NetNamedPipeBinding(),"test_service_a"); hostA.open(); hostB.AddServiceEndpoint(typeof (ContractB),"test_service_b"); hostB.open(); while(true)dowork(); } } //CALLING SERVICE A //uncomment the following line to reuse the same ChannelFactory each time //private static readonly ChannelFactory<ContractA> pipeFactory=new ChannelFactory<ContractA>(new NetNamedPipeBinding(),new EndpointAddress("net.pipe://localhost/test_service_a")); private static void dowork() { //comment the following line to reuse the same ChannelFactory each time var pipeFactory = new ChannelFactory<ContractA>(new NetNamedPipeBinding(),new EndpointAddress("net.pipe://localhost/test_service_a")); ContractA provider = null; try { provider = pipeFactory.CreateChannel(); provider.DoWork(); } catch { } finally { CloseChannel(provider); //comment the following line to reuse the same ChannelFactory each time try { pipeFactory.Close(); }catch{pipeFactory.Abort();} } } private static void CloseChannel(ContractA provider) { try { if (provider == null) return; try { ((IClientChannel) provider).Close(); } catch { ((IClientChannel) provider).Abort(); } ((Idisposable) provider).dispose(); } catch (Exception ex) { throw new Exception("Error while closing channel",ex); } } } [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single,ConcurrencyMode = ConcurrencyMode.Multiple)] public class ServiceA : ContractA { //CALLING SERVICE B //uncomment the following line to reuse the same ChannelFactory each time //private readonly ChannelFactory<ContractB> pipeFactory=new ChannelFactory<ContractB>(new NetNamedPipeBinding(),new EndpointAddress("net.pipe://localhost/test_service_b")); public void DoWork() { //comment the following line to reuse the same ChannelFactory each time var pipeFactory=new ChannelFactory<ContractB>(new NetNamedPipeBinding(),new EndpointAddress("net.pipe://localhost/test_service_b")); ContractB provider = null; try { provider = pipeFactory.CreateChannel(); provider.DoWork(); } catch { } finally { CloseChannel(provider); //comment the following line to reuse the same ChannelFactory each time try { pipeFactory.Close(); } catch { pipeFactory.Abort(); } } } private void CloseChannel(ContractB provider) { try { if (provider == null) return; try { ((IClientChannel) provider).Close(); } catch { ((IClientChannel) provider).Abort(); } ((Idisposable) provider).dispose(); } catch (Exception ex) { throw new Exception("Error while closing channel",ex); } } } [ServiceContract] public interface ContractA { [OperationContract] void DoWork(); } [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single,ConcurrencyMode = ConcurrencyMode.Multiple)] public class ServiceB : ContractB { public void DoWork() { } } [ServiceContract] public interface ContractB { [OperationContract] void DoWork(); } }
解决方法
尝试在App.config中打开服务器垃圾回收模式,看看行为是否发生了变化.这应该允许GC工作直到完成.
<configuration> <runtime> <gcServer enabled="true"/> </runtime> </configuration>
我假设你使用的是多核系统,否则这将是零影响.
今天关于无法从Windows服务连接到WCF服务和无法从服务器获取最新更新,请稍后重试的介绍到此结束,谢谢您的阅读,有关Azure函数无法访问内部Windows服务器中托管的WCF服务、c# – WCF服务托管在Windows服务运行比控制台应用程序慢10倍、c# – Windows服务托管TCP WCF服务、c# – 从另一个WCF服务中调用WCF服务时WCF内存泄漏等更多相关知识的信息可以在本站进行查询。
本文标签: