gpt4 book ai didi

asp.net - 找不到类型 'RestService.weddingservice',在 ServiceHost 指令中作为服务属性值提供

转载 作者:行者123 更新时间:2023-12-01 10:06:43 24 4
gpt4 key购买 nike

我正在尝试创建我的第一个 WCF Restful 服务。在 VS2010 中,我打开 weddingservice.svc 然后按 F5。浏览器打开 http://localhost:50043/weddingservice.svc但是,这是我得到的错误:

Server Error in '/' Application.

The type 'RestService.weddingservice', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The type 'RestService.weddingservice', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[InvalidOperationException: The type 'RestService.weddingservice', 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) +51530
System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1461
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +44
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +651

[ServiceActivationException: The service '/weddingservice.svc' cannot be activated due to an exception during compilation. The exception message is: The type 'RestService.weddingservice', 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) +688590
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +190
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, String routeServiceVirtualPath, Boolean flowContext, Boolean ensureWFService) +234
System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +359
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

在我的代码下面,我希望任何人都能看到我做错了什么。我没有使用正确的 URI 吗?我错过了什么?

婚礼服务.svc

<%@ ServiceHost Language="VB" Debug="true" Service="RestService.weddingservice" CodeBehind="weddingservice.svc.vb" %>

Iweddingservice.vb

Imports System.ServiceModel
Imports System.Web
Imports System.IO
Imports System.Runtime.Remoting.Activation
Imports System.Collections.Generic

Namespace RestService
<ServiceContract()>
Public Interface Iweddingservice

<OperationContract()> _
<Web.WebGet(UriTemplate:="job/{name}")> _
Function DoJob(name As String) As String

End Interface
End Namespace

weddingservice.svc.vb

Imports System.ServiceModel
Imports System.ServiceModel.Web
Imports System.IO
Imports System.ServiceModel.Activation
Imports System.Web.Script.Serialization
Imports System.Collections.Generic
Imports System.Xml
Imports System.Net

Namespace RestService
Public Class weddingservice
Implements Iweddingservice

Public Function DoJob(name As String) As String Implements Iweddingservice.DoJob
Return String.Format("Hello, {0}", name)
End Function
End Class
End Namespace

web.config

<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="weddingservice">
<endpoint binding="webHttpBinding" contract="RestService.Iweddingservice" behaviorConfiguration="webHttp"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webHttp">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>

最佳答案

设置

<serviceDebug includeExceptionDetailInFaults="false" />

<serviceDebug includeExceptionDetailInFaults="true" />

为了得到更多的细节

并尝试再次运行该进程

关于asp.net - 找不到类型 'RestService.weddingservice',在 ServiceHost 指令中作为服务属性值提供,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9557221/

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