0

何らかの理由で、Visual Studio 2010 デバッガーを WCF サービス ライブラリを使用するサービスにアタッチできません。ここから MSDN チュートリアルに従いました。サービスをインストールして実行すると問題なく動作し、クライアント GUI からすべてにアクセスできますが、デバッガーをサービスにアタッチしようとすると、次のような WCF サービス ホスト ウィンドウが表示され、エラーが表示されます。 :

System.ServiceModel.AddressAlreadyInUseException: There is already a listener on IP endpoint 0.0.0.0:8000.  Make sure that you are not trying to use this endpoint multiple times in your application and that there are no other applications listening on this endpoint. ---> System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted
   at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Bind(EndPoint localEP)
   at System.ServiceModel.Channels.SocketConnectionListener.Listen()
   --- End of inner exception stack trace ---
   at System.ServiceModel.Channels.SocketConnectionListener.Listen()
   at System.ServiceModel.Channels.ConnectionAcceptor.StartAccepting()
   at System.ServiceModel.Channels.ExclusiveTcpTransportManager.OnOpen()
   at System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener)
   at System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback)
   at System.ServiceModel.Channels.TcpChannelListener`2.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info)
System.Net.Sockets.SocketException (0x80004005): Only one usage of each socket address (protocol/network address/port) is normally permitted
   at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Bind(EndPoint localEP)
   at System.ServiceModel.Channels.SocketConnectionListener.Listen()

OnStart()以下に示すように、サービス内の関数の myServiceHost.open() で問題が発生しています。

public partial class ORAS : ServiceBase
    {
        System.Timers.Timer aTimer;
        OWcfServiceLibrary.OService ORAS = new OService();
        internal static ServiceHost myServiceHost = null; 
        public ORAS()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            System.Diagnostics.Debugger.Launch();
            aTimer = new System.Timers.Timer(60000);//every minute
            aTimer.AutoReset = true;
            aTimer.Elapsed += new System.Timers.ElapsedEventHandler(aTimer_Has_Alarm);
            aTimer.Enabled = true;
            if (myServiceHost != null)
            {
                myServiceHost.Close();
            }
            myServiceHost = new ServiceHost(typeof(OrionService));
            myServiceHost.Open();
        }
4

1 に答える 1

2

のようなものを 2 回試みたように見えますserviceHost.AddServiceEndpoint()。1 回目はサービス自体で、次にデバッグを開始したときです。

次の場合は、サービス コードにステップインできます。

  1. Visual Studio を「管理者として」実行します。
  2. サービスを実行して準備を整えます。
  3. クライアント コードをデバッグで開始し、サービスを呼び出す行にブレークポイントを設定します。

クライアント コードがブレークポイントに達したら、 を使用Step Into (F11)してサービス コードに移動します。正しく設定されていれば、ステップ実行を続行できるサービス コードにシームレスに変換されます。

別の方法:

  1. サービスを停止します。
  2. サービスのOnStart()メソッドで、次の行を最初に配置します。 System.Diagnostics.Debugger.Launch();
  3. サービスを再構築してから開始する
  4. その新しいコード行がヒットすると、デバッガーを選択するように求められます...既に開いているプロジェクトを選択します

launch()それはあなたを新しい行に落とすはずです。

于 2013-08-13T17:30:49.473 に答える