пример сервиса на WCF, не работает
От: IvanLev  
Дата: 20.07.09 08:48
Оценка:
хочу попробовать WCF для IIS 6.0 ( IIS 7.0 не надо предлагать )
создал в виртальной директории файлы

service.svc:
<%@ServiceHost language=c# Debug="true" Service="example.calc" CodeBehind="C:\Inetpub\TestService\Site\service.svc.sc" %>
-------------------------
service.svc.sc:
namespace example
{
[ServiceContract]
public interface ICalc
{
[OperationContract]
double Add(double n1, double n2);
}

public class calc : ICalc
{
public double Add(double n1, double n2)
{
return n1 + n2;
}
}
}
-------------------------
web.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
<system.serviceModel>
<services>
<service name="example.calc">
<endpoint address="" binding="wsHttpBinding" contract="example.ICalc" />
</service>
</services>
</system.serviceModel>
</configuration>

-------------------------
попробовал зайти http://10.0.0.1:6666/service.svc
а в ответ ошибки что не может найти класс, почему?

Server Error in '/' Application.
The type 'example.calc', provided as the Service attribute value in the ServiceHost directive 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 'example.calc', provided as the Service attribute value in the ServiceHost directive 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 'example.calc', provided as the Service attribute value in the ServiceHost directive could not be found.]
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +4073642
System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +11659932
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +42
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +479

[ServiceActivationException: The service '/service.svc' cannot be activated due to an exception during compilation. The exception message is: The type 'example.calc', provided as the Service attribute value in the ServiceHost directive could not be found..]
System.ServiceModel.AsyncResult.End(IAsyncResult result) +11531006
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +194
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext) +176
System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +278
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.