2011-01-03 2 views
0

Je suis nouveau avec WCF. Je crée wcf pour le scénario d'impression côté serveur ... Je héberge wcf dll sur l'application console. Voici mon code:WCF sur Windows 7 pourquoi ne pas travailler.?

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(); 
     } 

    } 
} 

Et voici mon 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> 

Ce code fonctionne sous Windows XP .... Pourquoi son travail pas si je fonctionner sur Windows 7? Je l'exécute en tant qu'administrateur et avec le pare-feu éteint.

Le document n'apparaît que dans la file d'attente d'impression et disparaît sans avertissement ni erreur ... Mais l'impression n'a pas vraiment lieu.

Répondre

1

Ce code fonctionne sous Windows XP .... Pourquoi son travail ne fonctionne pas si je l'exécute sur Windows 7?

Vous devez exécuter l'application (d'hébergement) en tant qu'administrateur. L'ouverture d'un port d'écoute est une opération privilégiée.

Questions connexes