WCF服务启动时系统挂起 [英] System hangs when wcf service is started

查看:64
本文介绍了WCF服务启动时系统挂起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我已经在Win Form应用程序中创建了一个自托管的wcf服务.一切正常(通信)...
问题:我的应用程序在系统启动时启动,并且一旦我的应用程序启动,它将触发我的wcf服务启动"selfHost.Open()"
但是主要的问题是它挂断了系统.使该应用程序在20 30秒内无法使用.
你们有没有解决的办法.
在此先感谢
Nitin Verma

Hi All,
I have created a self hosted wcf service in a win form app. Every thing works fine(the communication)...
Problem: My application starts on system startup, and as soon as my app starts it triggers my wcf service to start "selfHost.Open()"
but the main problem is it hangs up the system. making the application not usable for aroung 20 30 seconds.
Do any of you have a solution.
Thanks in advance
Nitin Verma

推荐答案

在单独的线程中使用所有通信部分.甚至不用玩没有线程就可以进行网络,远程处理或WCF的想法.

—SA
Use all communication part in a separate thread. Don''t even play with the idea of doing networking, remoting or WCF without threading.

—SA


感谢SA,
我已经在saperate线程中启动了wcf服务,但是仍然挂起了系统,
我猜问题出在某种程度上与系统启动有关,因为当我注销并登录XP时它不会挂起.
但是仅当我重新启动系统时才会出现问题.
尼丁
Thanks SA,
I have started the wcf service in saperate thread, but still it hangs the system,
I guess the problem is somewhat related to the system startup, Because it does not hang when I logoff and login the XP.
But the problem only occurs when I restart the system.
Nitin


再次感谢,

但请注意,我没有连接到wcf服务.我正在尝试开始一个.

我尝试过,在尝试启动网络连接之前,它已经获取了IP.我已经编写了以下代码来启动该服务.

Thanks again,

but le me be clear that I am not connecting to a wcf service. I am trying to start a one.

And I tried that Before trying to start it network connection has acquired IP. I have written below code to start the service.

 Dim baseAddress As Uri = New Uri("http://localhost:8080/me/myService")

 Dim selfHost As New ServiceHost(GetType(WCFService), baseAddress)
 
 selfHost.AddServiceEndpoint(GetType(MyContract.IServerManager), New WSHttpBinding(SecurityMode.None), "WCFService")

 Dim smb As New ServiceMetadataBehavior()
            smb.HttpGetEnabled = True
            selfHost.Description.Behaviors.Add(smb)
selfHost.Open()


这篇关于WCF服务启动时系统挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆