Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WCF服务启动错误-服务没有应用程序终结点_C#_Visual Studio 2010_Wcf - Fatal编程技术网

C# WCF服务启动错误-服务没有应用程序终结点

C# WCF服务启动错误-服务没有应用程序终结点,c#,visual-studio-2010,wcf,C#,Visual Studio 2010,Wcf,我正在尝试启动windows服务,但出现以下错误: 服务无法启动。System.InvalidOperationException:服务 “LazyPCAndroiderSvc.LazyPCController”的应用程序为零 (非基础设施)端点。这可能是因为没有配置 找不到应用程序的文件,或者因为没有服务元素 在配置文件中可以找到匹配的服务名称,或者 因为服务元素中未定义终结点 ? 我已经使用WCF Tester测试了该服务,它没有带来任何问题。只有当我尝试将其作为windows服务运行时,才

我正在尝试启动windows服务,但出现以下错误:

服务无法启动。System.InvalidOperationException:服务 “LazyPCAndroiderSvc.LazyPCController”的应用程序为零 (非基础设施)端点。这可能是因为没有配置 找不到应用程序的文件,或者因为没有服务元素 在配置文件中可以找到匹配的服务名称,或者 因为服务元素中未定义终结点

?

我已经使用WCF Tester测试了该服务,它没有带来任何问题。只有当我尝试将其作为windows服务运行时,才会导致上述错误

以下是wcf服务中的my app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <!-- This section is optional with the new configuration model
           introduced in .NET Framework 4. -->
      <service name="LazyPCAndroiderSvc.LazyPCController"
               behaviorConfiguration="LazyPCControllerBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8750/LazyPCAndroiderSvc/LazyPCController/"/>
          </baseAddresses>
        </host>

        <endpoint address=""
                  binding="wsHttpBinding"
                  contract="LazyPCAndroiderSvc.ILazyPCController" />

        <endpoint address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="LazyPCControllerBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

这似乎是个小问题,但我找不到原因。

服务可能不会自动读取
lazypcandoridersvc.dll.config
-将这些配置放在主exe的App.config

服务指向的exe的路径是什么?该位置是否存在.exe.config?@YK1 WCF服务是作为引用加载的VS解决方案的一部分,因此它是一个DLL。所有LazyPCAndroiderSvc.dll,LazyPCAndroiderSvc.dll。WCF服务文件夹中存在config、App.config。抱歉,我有点困惑,您是说我需要将LazyPCAndroiderSvc.dll.config路径放入Windows Service exe配置中吗?(懒散的人)?我该怎么做?我找不到windows服务的app.config,它只存在于我的WCF服务中。请将app.config添加到EXE项目中。将dll.config的system.ServiceModel内容复制到exe.config.Wow,这就解决了问题!这是相当令人困惑,但它的工作,我做了其他更愚蠢的事情。。。我的app.config文件名为app.cfg。造成了同样的错误,我花了一天的时间才找到它。
namespace LazyPCAndroiderWinSvc
{
    public partial class Service : ServiceBase
    {
        ServiceHost sHost;
        public Service()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            sHost = new ServiceHost(typeof(LazyPCAndroiderSvc.LazyPCController));
            sHost.Open();
        }

        protected override void OnStop()
        {
            sHost.Close();
        }
    }
}