简体   繁体   English

重命名WCF服务时出现问题

[英]Issues when renaming WCF Service

first of all, I am well aware that there are two other questions about the same topic I'm about to inquire, and I must sadly say that they haven't worked for me. 首先,我很清楚关于我即将询问的同一主题还有另外两个问题,我必须遗憾地说他们没有为我工作。

As it stands I am trying to create a simple WCF service which is to be consumed by a desktop application. 我正在尝试创建一个由桌面应用程序使用的简单WCF服务。 I created it off the WCF Service Application that is offered through the New -> Project in Visual Studio 2013. That project has a template which has these two files: An interface called IService1.cs and the Service which is called Service1.svc. 我通过Visual Studio 2013中的New - > Project提供的WCF服务应用程序创建了它。该项目有一个模板,其中包含以下两个文件:一个名为IService1.cs的接口和一个名为Service1.svc的服务。

Right out of the box this whole package works, but when I decide to rename those files with "IReservationService" and "ReservationService" respectively and put in my own code (which I can't find any mistakes in, not yet), when I decide to see if it's all working I get this bad boy: 开箱即用这整个包工作,但当我决定分别用“IReservationService”和“ReservationService”重命名这些文件并输入我自己的代码(我找不到任何错误,还没有),当我决定看看它是否全部正常我得到了这个坏男孩:

重构(?)错误。

I regret to tell you that some parts of it are in Spanish, if you can't interpret them just yell at me and I will translate all of it for you. 我很遗憾地告诉你,它的某些部分是西班牙语,如果你不能解释它们只是对我大喊大叫,我将为你翻译所有这些内容。

This is the code involved: 这是涉及的代码:

IReservationService.cs IReservationService.cs

namespace WebService
{
    [ServiceContract]
    public interface IReservationService
    {
        [OperationContract]
        List<Business.Reservation> RequestReservationRetrieval();
    }
}

ReservationService.svc ReservationService.svc

namespace WebService
{
    public class ReservationService : IReservationService, IDisposable
    {
        ReservationRepository repo;

        public List<Business.Reservation> RequestReservationRetrieval()
        {
            //code goes here, skipped it so it doesn't clutter
        }

        private void ChangeSyncDate(DateTime date)
        {
            //code goes here, skipped it so it doesn't clutter
        }

        public void Dispose()
        {
            repo.Dispose();
        }
    }
}

As soon as I change the code in those two classes (IService1.cs and Service1.svc) which I assumed would have been refactored for mine to fit somewhat perfectly, that doesn't seem to be the case, and I get the error that is displayed in the image. 一旦我改变了这两个类中的代码(IService1.cs和Service1.svc),我认为这些代码将被重构为我的某些方面完全适合,但似乎并非如此,我得到的错误是显示在图像中。

Any ideas on how to fix this? 有想法该怎么解决这个吗?

This was pretty much a refactoring nightmare, because the issue was somewhat hidden. 这几乎是一个重构的噩梦,因为这个问题有点隐藏。

There's two files in ReservationService, or rather the Service that's to be consumed, in my case: 在我的情况下,ReservationService中有两个文件,或者更确切地说是要使用的服务:

ReservationService.svc and ReservationService.svc.cs ReservationService.svc和ReservationService.svc.cs

ReservationService.svc contains just this tiny line: ReservationService.svc只包含这一小行:

<%@ ServiceHost Language="C#" Debug="true" Service="WebService.Service1" CodeBehind="ReservationService.svc.cs" %>

And oh, surprise, there it is. 哦,惊喜,就是这样。 Service="WebService.Service1" is exactly what was causing all these issues. Service =“WebService.Service1”正是造成所有这些问题的原因。

In order to get to ReservationService.svc, or whatever it's called on your Project you need to Right Click the .svc and click "View Markup". 要访问ReservationService.svc,或者在项目中调用它,您需要右键单击.svc并单击“查看标记”。

This is an issue no one should ever have to deal with, I swear. 我发誓,这是一个任何人都不应该处理的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM