gpt4 book ai didi

c# - 类型 '*' ,作为 ServiceHost 指令中的 Service 属性值提供,或在配置元素中提供 * 无法找到

转载 作者:行者123 更新时间:2023-11-30 17:45:14 25 4
gpt4 key购买 nike

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

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

但是,发布网络服务后不起作用,我收到此异常:

[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);
}
}

最佳答案

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

例如:

namespace my{

public class DummyService: IWebService
{
//implementation
}
}

*.svc 标记:<%@ ServiceHost Language="C#"Debug="true"Service="my.DummyService"CodeBehind="myservice.svc.cs"%>

  • 尝试检查一下: WCF Web Service not working after IIS restart
  • “有趣的是,预编译 Web 服务时会引发上述错误。我尝试定期运行该服务(无需预编译),但该问题不再出现。

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

  • 您可以检查您的服务的应用程序池吗?开始了吗?
  • 关于c# - 类型 '*' ,作为 ServiceHost 指令中的 Service 属性值提供,或在配置元素中提供 * 无法找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28100605/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com