【问题标题】:the type '*', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element * could not be found类型“*”,作为 ServiceHost 指令中的服务属性值提供,或在配置元素中提供 * 找不到
【发布时间】:2015-01-22 23:32:15
【问题描述】:

我在 sharepoint 中有一个提供商托管的应用程序,可以在本地正常运行。我按照本教程将其发布到 azure

http://blogs.technet.com/b/sharepointdevelopersupport/archive/2013/09/05/how-to-deploy-a-provider-hosted-app-as-an-azure-site.aspx

但是,在发布 web 服务不起作用后,我得到了这个异常:

[InvalidOperationException: The type 'x.IntranetWeb.Services.AppEventReceiver', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.]
   System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +62739
   System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +1429
   System.ServiceModel.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity) +52
   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +598

[ServiceActivationException: The service '/Services/AppEventReceiver.svc' cannot be activated due to an exception during compilation.  The exception message is: The type 'x.IntranetWeb.Services.AppEventReceiver', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found..]
   System.Runtime.AsyncResult.End(IAsyncResult result) +486572
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +174
   System.ServiceModel.Activation.ServiceHttpModule.EndProcessRequest(IAsyncResult ar) +345998
   System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +9683593

我没有碰过的 web.config。

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=301880
  -->
<configuration>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="ClientId" value="xx-04e7-4caf-854a-89c20577d7da" />
    <add key="ClientSecret" value="ljguTvxHR+xx+Pl1IMg1Hjt5rsQ=" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <customErrors mode="Off"/>
  </system.web>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.2.0.0" newVersion="5.2.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <!--Used by app for SharePoint-->
        <binding name="secureBinding">
          <security mode="Transport" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <protocolMapping>
      <add binding="basicHttpBinding" scheme="https" bindingConfiguration="secureBinding" />
    </protocolMapping>
  </system.serviceModel>
  <system.webServer>
    <handlers>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>
</configuration>

以及远程事件接收器的一段代码

<%@ ServiceHost Language="C#" Debug="true" Service="x.IntranetWeb.Services.AppEventReceiver" CodeBehind="AppEventReceiver.svc.cs" %>


namespace x.IntranetWeb.Services
{
    public class AppEventReceiver : IRemoteEventService
    {

还有 global.asax,因为这是一个带有 .svc 的 MVC 应用程序,也许它与路由有关?

public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
    }

【问题讨论】:

  • 你能试试吗,从配置中删除handlers 部分,部署到天蓝色!如果有帮助,请告诉我。并确保您在代码隐藏文件中有AppEventReceiver 类,即AppEventReceiver.svc.cs
  • 确保“x.IntranetWeb.Services.AppEventReceiver”类型所在的程序集存在于 bin 目录中,并且 bin 目录应与您的 .svc 文件处于同一级别。
  • 有趣的是,实际上有一个名为 Services 的文件夹和 AppEventReceiver,所以它不在 bin 文件夹的同一级别,有什么理由可以在本地而不是在 azure 上工作?
  • @ArindamNayak 删除处理程序部分没有任何区别

标签: c# asp.net asp.net-mvc wcf azure


【解决方案1】:
  1. 检查您的服务类名称,它应该与 *.svc 标记文件“Service = ...”中的名称相同

例如:

namespace my{

     public class DummyService: IWebService
     {
        //implementation
     }
}

*.svc 标记:my.DummyService" CodeBehind="myservice.svc.cs" %>

  1. 尝试检查: WCF Web Service not working after IIS restart

“有趣的是,在预编译 Web 服务时触发了上述错误。我尝试定期运行该服务(不进行预编译),但问题不再出现。

我在 Web 服务中使用了一个库,所以实际上 Web 服务本身根本没有任何代码。也许这就是原因。不管怎样,因为没有代码,所以没有预编译也可以”

  1. 您可以为您的服务检查应用程序池吗?开始了吗?

【讨论】:

  • 请检查我粘贴的代码,它是一样的,而且它在本地工作,你能解释一下为什么它在本地工作但在天蓝色不工作吗??
  • Nr 1 是正确的,Nr 2 和 3 我无法控制,因为将其托管在 Windows azure 中。
  • 尝试使用默认 web.config 创建默认 WCF 服务并在 azure 上发布。
  • 如何让它不被预编译??
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多