WCF的错误,服务“**********”有零个应用程序(非基础结构)终结点
配置文件:<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="customBinding0">
<binaryMessageEncoding />
<httpTransport />
</binding>
</customBinding>
</bindings>
<services>
<service name="WcfServiceConfig.ServiceConfig" behaviorConfiguration="configerror">
<endpoint address="" binding="basicHttpBinding" contract="WcfServiceConfig.IServiceConfig">
<identity >
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:18888/ServiceConfig/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="configerror">
<!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
<serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:18989/ServiceConfig/"/>
<!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
启动服务:
ServiceHost host = new ServiceHost(typeof(ServiceConfig));
host.Open();
Console.WriteLine("服务已经启动....");
Console.ReadLine();
服务:[img=http://][/img] wcf --------------------编程问答-------------------- IIS的不太清楚,毕竟用WCF再用IIS本身就有点画蛇添足的感觉,有些设置会和IIS设置冲突,比如httpGetUrl、baseAddress,这些地址都是通过IIS配置的,不能从配置文件里指定,你越权了。你只能指定相对地址,无法指定绝对地址。 --------------------编程问答-------------------- 没有用IIS,只是用VS提供的服务器运行的 --------------------编程问答--------------------
我看到了
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
所以第一反映你是IIS里运行的。
建议你用WCF配置工具来配置config文件,那样就不会配错里面的节点。
http://msdn.microsoft.com/zh-cn/library/ms732009.aspx --------------------编程问答-------------------- 看到有endpoint 啊。 --------------------编程问答--------------------
所以我也奇怪啊,都搞了一天了,网上的办法差不多都试完了,但还是没一个能解决这个问题 --------------------编程问答-------------------- 用个最简单的试一试:
http://msdn.microsoft.com/en-us/library/ee530014.aspx --------------------编程问答-------------------- 大神们,如果不用ServiceHost,还有其它启动方法吗?如只通过配置文件之类的东西 --------------------编程问答-------------------- 你用那个工具来配置了吗?我不会在配置文件里放无关的配置,但你的配置文件里面,放了很多无关配置(web下用的),你能不能先删除它们。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<services>
<service name="WcfServiceConfig.ServiceConfig" behaviorConfiguration="configerror">
<endpoint binding="basicHttpBinding" address = "ServiceConfig" contract="WcfServiceConfig.IServiceConfig">
<identity >
<dns value="localhost"/>
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:18888/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="configerror">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
试试这样,完全足够了。 --------------------编程问答--------------------
还是不行啊,兄台,那个也是手写的,只不过用的是WCF应用程序生成的那个,因为我添加的是WCF应用程序,而不是类库,还有什么办法吗,大神!
--------------------编程问答-------------------- --------------------编程问答--------------------
我想是不是你添加的那个WCF程序本身有问题,你可以试试自己写一个WCF简单的服务出来调试下,或者用微软的示例,config文件就模仿上面给的,按理说配置文件没问题了。
补充:.NET技术 , C#