2011-01-03 13 views
0

WCFの新機能です。私はwcfをサーバーサイドの印刷シナリオ用に作成します...私はコンソールアプリケーションでwcf dllをホストします。以下は私のコードです:Windows 7のWCFなぜ動作しないのですか?

class Program 
{ 
    static void Main(string[] args) 
    { 
     using (ServiceHost host = new ServiceHost(typeof(PrintBarcode))) 
     { 
      host.Open(); 
      Console.WriteLine("The service is ready..."); 
      Console.WriteLine("Press <Enter> to stop the service."); 
      Console.ReadLine(); 
      host.Close(); 
     } 

    } 
} 

そして、これは私のapp.configです:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.web> 
    <compilation debug="true" /> 
    </system.web> 
    <!-- When deploying the service library project, the content of the config file must be added to the host's 
    app.config file. System.Configuration does not support config files for libraries. --> 
    <system.serviceModel> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> 
    <services> 
     <service behaviorConfiguration="CTIHandHeld.WCF.PrintBarcodeWcfServiceLibrary.Service1Behavior" 
     name="CTIHandHeld.WCF.PrintBarcodeWcfServiceLibrary.PrintBarcode"> 
     <endpoint address="" binding="netTcpBinding" bindingConfiguration="TcpBindingConfiguration" 
      contract="CTIHandHeld.WCF.PrintBarcodeWcfServiceLibrary.IPrintBarcode" /> 
     <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" 
      contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="net.tcp://localhost:3518/PrintBarcodeService" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <bindings> 
     <netTcpBinding> 
     <binding name="TcpBindingConfiguration"> 
      <security mode="Transport"/> 
     </binding> 
     </netTcpBinding> 
    </bindings> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="CTIHandHeld.WCF.PrintBarcodeWcfServiceLibrary.Service1Behavior"> 
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" /> 
      <serviceDebug includeExceptionDetailInFaults="false" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
</configuration> 

コードは、Windows XPで動作することを....私は、Windows 7上でそれを実行している場合、その動作しないのはなぜ?私はそれを管理者として実行し、ファイアウォールをオフにしています。

文書は印刷キューにのみ表示され、警告またはエラーなしで消えます...しかし、印刷は実際には起こりません。

答えて

1

そのコードはWindows XPで動作します...なぜ私はWindows 7でそれを実行している場合は動作しません?

(ホスティング)アプリケーションを管理者として実行する必要があります。リスニングのためにポートを開くことは特権操作です。

関連する問題