在IIS7上部署WCF教程应用程序:“;找不到类型";

在IIS7上部署WCF教程应用程序:“;找不到类型";,wcf,iis-7,iis-manager,Wcf,Iis 7,Iis Manager,我一直在尝试遵循这一点,将WCF示例部署到IIS。 我不能让它工作。这是一个托管站点,但我确实可以访问服务器的IIS管理器。但是,在本教程的步骤2中,我无法“创建物理上位于此应用程序目录中的新IIS应用程序”。我似乎找不到菜单项、上下文菜单项或不创建新应用程序的内容。我疯狂地右键点击了所有地方,但仍然不知道如何创建一个新的应用程序。我想这可能是根本问题,但我尝试了其他一些方法(如下所述),以防万一这不是问题所在。以下是我在IIS管理器中看到的图片,以防我的话不公正: 这是“部署”在。错误显示:

我一直在尝试遵循这一点,将WCF示例部署到IIS。 我不能让它工作。这是一个托管站点,但我确实可以访问服务器的IIS管理器。但是,在本教程的步骤2中,我无法“创建物理上位于此应用程序目录中的新IIS应用程序”。我似乎找不到菜单项、上下文菜单项或不创建新应用程序的内容。我疯狂地右键点击了所有地方,但仍然不知道如何创建一个新的应用程序。我想这可能是根本问题,但我尝试了其他一些方法(如下所述),以防万一这不是问题所在。以下是我在IIS管理器中看到的图片,以防我的话不公正:

这是“部署”在。错误显示:

    The type 'Microsoft.ServiceModel.Samples.CalculatorService', 
provided as the Service attribute value in the ServiceHost directive, 
or provided in the configuration element
 system.serviceModel/serviceHostingEnvironment/serviceActivations 
could not be found.
我还尝试在dotnetpanel中创建一个指向IISHostedCalc服务的虚拟目录(IISHostedCalc)。当我导航到时,会出现另一个错误:

This collection already contains an address with scheme http.  
There can be at most one address per scheme in this collection.
有趣的是,如果我点击查看应用程序,虚拟目录似乎就是一个应用程序(见下图)。。。但是,根据上面的错误消息,它不起作用

根据教程,没有涉及编译;我刚刚将文件放在服务器上,如下所示,放在文件夹IISHostedCalcService中:

service.svc
Web.config
<dir: App_Code>
   Service.cs

好吧,看来这是我干的。我仍然无法在IIS管理器中找到“创建应用程序”项。这一部分有点令人沮丧,但我很高兴它似乎无论如何都能起作用

我已经在wwwroot下创建了物理目录IISHostedCalcService。这造成了一些混乱;这意味着这几乎是可行的,但它不应该。我把IISHostedCalcService移到了wwwroot之外,现在唯一可以访问该服务的地方是

然后,访问时抛出“此集合已包含一个带有方案http的地址。
此集合中每个方案最多只能有一个地址。“错误。解决方案是将以下内容添加到web.config文件中,就在system.serviceModel下:

<serviceHostingEnvironment>
  <baseAddressPrefixFilters>
    <add prefix="http://test.com.cws1.my-hosting-panel.com"/>
  </baseAddressPrefixFilters>
</serviceHostingEnvironment>

:“在服务计算器服务实现的合同列表中找不到合同名称IMAdataExchange”。解决方案是如下修改web.config文件(即,在服务元素中添加behaviors部分和behaviorConfiguration=“SimpleServiceBehavior”):


在教程的步骤5c中。然而,当我运行客户端时,我得到了一个“调用方未通过服务验证”错误。解决方案最简单:只需将服务的web.config和客户端的web.config中的binding=“wsHttpBinding”更改为binding=“basicHttpBinding”(或者在更改服务的web.config后重新运行svcuti)

web.config的最终外观如下所示:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <serviceHostingEnvironment>
      <baseAddressPrefixFilters>
        <add prefix="http://test.com.cws1.my-hosting-panel.com"/>
      </baseAddressPrefixFilters>
    </serviceHostingEnvironment>
    <services>
      <service name="Microsoft.ServiceModel.Samples.CalculatorService" behaviorConfiguration="SimpleServiceBehavior">

        <!-- This endpoint is exposed at the base address provided by host:                                        http://localhost/servicemodelsamples/service.svc  -->
        <endpoint address=""
                  binding="basicHttpBinding"
                  contract="Microsoft.ServiceModel.Samples.ICalculator" />

        <!-- The mex endpoint is explosed at http://localhost/servicemodelsamples/service.svc/mex -->            
        <endpoint address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange" />

      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="SimpleServiceBehavior">
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true" policyVersion="Policy15" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  <system.web>
    <customErrors mode="Off"/>
  </system.web>
</configuration>


要创建新的应用程序,右键单击默认网站节点。从上下文菜单中选择添加应用程序。

我也有同样的错误,对我来说,问题只是服务器上缺少服务编译所需的程序集

这里所描述的一切对我来说都不是必需的

要找出错误,可以尝试将service.svc和service.svc.cs文件移动到App_Code目录。这样,您将得到一条与实际错误更相关的错误消息

在我的例子中,名称空间丢失,因为我忘记部署一些程序集。我上载了丢失的程序集,正确运行服务,然后将服务文件移回它们所属的位置。

我遇到了这个问题

  • 我将发布的文件保存在wwwroot下
  • 单击浏览.svc文件
  • 这也引发了同样的异常
  • 决议

  • 我为同一个目录创建了一个虚拟目录
  • 尝试浏览.svc文件

  • 工作…

    我也有这个问题。我需要在一个引用的程序集上设置“Copy Local”以将其包含在我的站点中。在执行所有这些操作之前,请尝试添加应用程序(jdc的答案)。。。这对我来说容易多了!
    using System;
    using System.ServiceModel;
    
    namespace Microsoft.ServiceModel.Samples
    {
    
        [ServiceContract]
        public interface ICalculator
        {
            [OperationContract]
            double Add(double n1, double n2);
            [OperationContract]
            double Subtract(double n1, double n2);
            [OperationContract]
            double Multiply(double n1, double n2);
            [OperationContract]
            double Divide(double n1, double n2);
        }
    
    
        public class CalculatorService : ICalculator
        {
            public double Add(double n1, double n2)
            {
                return n1 + n2;
            }
            public double Subtract(double n1, double n2)
            {
                return n1 - n2;
            }
            public double Multiply(double n1, double n2)
            {
                return n1 * n2;
            }
            public double Divide(double n1, double n2)
            {
                return n1 / n2;
            }
        }
    }
    
    <serviceHostingEnvironment>
      <baseAddressPrefixFilters>
        <add prefix="http://test.com.cws1.my-hosting-panel.com"/>
      </baseAddressPrefixFilters>
    </serviceHostingEnvironment>
    
    <configuration>
      <system.serviceModel>
        <serviceHostingEnvironment>
          <baseAddressPrefixFilters>
            <add prefix="http://test.com.cws1.my-hosting-panel.com"/>
          </baseAddressPrefixFilters>
        </serviceHostingEnvironment>
        <services>
          <service name="Microsoft.ServiceModel.Samples.CalculatorService" behaviorConfiguration="SimpleServiceBehavior">
          ...
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="SimpleServiceBehavior">
              <serviceMetadata httpGetEnabled="True" policyVersion="Policy15" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
      <system.web>
        <customErrors mode="Off"/>
      </system.web>
    </configuration>
    
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <system.serviceModel>
        <serviceHostingEnvironment>
          <baseAddressPrefixFilters>
            <add prefix="http://test.com.cws1.my-hosting-panel.com"/>
          </baseAddressPrefixFilters>
        </serviceHostingEnvironment>
        <services>
          <service name="Microsoft.ServiceModel.Samples.CalculatorService" behaviorConfiguration="SimpleServiceBehavior">
    
            <!-- This endpoint is exposed at the base address provided by host:                                        http://localhost/servicemodelsamples/service.svc  -->
            <endpoint address=""
                      binding="basicHttpBinding"
                      contract="Microsoft.ServiceModel.Samples.ICalculator" />
    
            <!-- The mex endpoint is explosed at http://localhost/servicemodelsamples/service.svc/mex -->            
            <endpoint address="mex"
                      binding="mexHttpBinding"
                      contract="IMetadataExchange" />
    
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="SimpleServiceBehavior">
              <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
              <serviceMetadata httpGetEnabled="true" policyVersion="Policy15" />
              <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
      <system.web>
        <customErrors mode="Off"/>
      </system.web>
    </configuration>