WCF on Windows 7 why not working.?
I new with WCF. I create wcf for server side printing scenario... I host wcf dll on console application. Below is my code:
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();
}
}
}
And thi开发者_Python百科s is my 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>
That code works in windows XP.... Why its not work if i running it on windows 7? I running it as administrator and with firewall turned off.
The document only appear in print queue and disappear without warning or error... But printing not really happen.
That code works in windows XP.... Why its not work if i running it on windows 7?
You need to run the (hosting) App as Administrator. Opening a port for listening is a privileged operation.
精彩评论