Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/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
未找到自托管WCF合约_Wcf_Silverlight_Sql Server 2008_Hosting - Fatal编程技术网

未找到自托管WCF合约

未找到自托管WCF合约,wcf,silverlight,sql-server-2008,hosting,Wcf,Silverlight,Sql Server 2008,Hosting,我使用此MSDN示例构建了我的控制台主机应用程序: 当我有一个正在运行的服务时,我可以将它作为服务引用添加到我的Silverlight类库ViewModel中,并且可以在浏览器中看到它正在运行 但是,当我运行Silverlight应用程序时,会收到以下错误消息: 找不到引用协定的默认终结点元素 ServiceModel客户端配置中的“ServiceLayer.IServiceLayer” 部分这可能是因为找不到的配置文件 您的应用程序,或者因为没有与此匹配的端点元素 可以在客户机元素中找到合同

我使用此MSDN示例构建了我的控制台主机应用程序:

当我有一个正在运行的服务时,我可以将它作为服务引用添加到我的Silverlight类库ViewModel中,并且可以在浏览器中看到它正在运行

但是,当我运行Silverlight应用程序时,会收到以下错误消息:

找不到引用协定的默认终结点元素 ServiceModel客户端配置中的“ServiceLayer.IServiceLayer” 部分这可能是因为找不到的配置文件 您的应用程序,或者因为没有与此匹配的端点元素 可以在客户机元素中找到合同

这是我的服务代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Activation;
using Model;

namespace ServiceLayer
{
    [ServiceContract(Namespace = "ServiceLayer")] //This has to match references or updating the service reference will not work.
    public interface IServiceLayer
    {
        [OperationContract] //This is needed for each method.
        string Compile(string cscode, string name, string type, int token);

        [OperationContract] //This is needed for each method.
        string LoginClick(string username, string password, bool createuser, int token);

        [OperationContract]
        bool IsLoggedIn(int token);

        [OperationContract] //This is needed for each method.
        object[] GetMessages(int token);

        [OperationContract] //This is needed for each method.
        int GetToken(int token);

        [OperationContract] //This is needed for each method.
        string[][] GetPlugins(int token);

        [OperationContract] //This is needed for each method.
        string Finalize(int token, string[] descriptions);

        [OperationContract] //This is needed for each method.
        object[][] Communicate(string methodName, int token, object[] args);
    }

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class ServiceLayer : IServiceLayer
    {
        public string Compile(string cscode, string name, string type, int token)
        {
            // Add your operation implementation here
            ModelInterface MI = new ModelInterface();
            return MI.Compile(cscode, name, type, token);
        }

        public String LoginClick(string username, string password, bool createuser, int token)
        {
            ModelInterface MI = new ModelInterface();
            return MI.LoginClick(username, password, createuser, token);
        }

        public bool IsLoggedIn(int token)
        {
            ModelInterface MI = new ModelInterface();
            return MI.IsLoggedIn(token);
        }

        public object[] GetMessages(int token)
        {
            ModelInterface MI = new ModelInterface();
            return MI.GetMessages(token);
        }

        public int GetToken(int token)
        {
            ModelInterface MI = new ModelInterface();
            return MI.GetToken(token);
        }

        public string[][] GetPlugins(int token)
        {
            ModelInterface MI = new ModelInterface();
            return MI.GetPlugins(token);
        }

        public string Finalize(int token, string[] descriptions)
        {
            ModelInterface MI = new ModelInterface();
            return MI.Finalize(token, descriptions);
        }

        public object[][] Communicate(string methodName, int token, object[] args)
        {
            ModelInterface MI = new ModelInterface();
            return MI.Communicate(methodName, token, args);
        }
        // Add more operations here and mark them with [OperationContract]
    }
}
这是ViewModel的ServiceReferences.ClientConfig:

<configuration>
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IServiceLayer" maxBufferSize="2147483647"
                maxReceivedMessageSize="2147483647">
                <security mode="None" />
            </binding>
            <binding name="BasicHttpBinding_IServiceLayer1" maxBufferSize="2147483647"
                maxReceivedMessageSize="2147483647">
                <security mode="None" />
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:3263/front" binding="basicHttpBinding"
            bindingConfiguration="BasicHttpBinding_IServiceLayer" contract="IServiceLayer"
            name="BasicHttpBinding_IServiceLayer" />
        <endpoint address="http://localhost:3263/front" binding="basicHttpBinding"
            bindingConfiguration="BasicHttpBinding_IServiceLayer1" contract="ServiceLayer.IServiceLayer"
            name="BasicHttpBinding_IServiceLayer1" />
    </client>
</system.serviceModel>
这是项目的Web.Config文件,该项目的网站托管了Silverlight应用程序。 我贴出来是因为我试过这个 指南-ie将servicemodel节从VM配置复制到下面的web.config:

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    <pages controlRenderingCompatibilityVersion="4.0"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <customBinding>
        <binding name="OrgOS.Web.ServerCommunicationService.customBinding0">
          <binaryMessageEncoding/>
          <httpTransport/>
        </binding>
        <binding name="OrgOS.Web.ServiceLayer.customBinding0">
          <binaryMessageEncoding/>
          <httpTransport/>
        </binding>
      </customBinding>
    </bindings>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
    <services>
      <service name="OrgOS.Web.ServiceLayer">
        <endpoint address="" binding="customBinding" bindingConfiguration="OrgOS.Web.ServiceLayer.customBinding0" contract="OrgOS.Web.ServiceLayer"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>
我租的服务器没有ASP.NET,尽管我付了钱,但支持人员正在休假,我的最后期限快到了! 试图让WCF工作快把我逼疯了-请帮帮我


为什么要展示一个简单的Silverlight项目这么难…

啊,没关系;您必须在View Silverlight项目、web项目和ViewModel Silverlight项目中发布配置设置

您还必须删除所有端点和绑定,但必须删除一个以避免混淆

还更改了一些内容,以确保namespace=namespace适合实际的名称空间

。。。并不是因为这个原因,我得到的只是无效的结果

FML现在