0

这是我在项目中添加服务引用时 Visual Studio 生成的代码。所有对“ReminderServiceClient.ServiceReference1.IReminderService”的引用都不起作用,因为它找不到“ServiceReference1”。但它定义在顶部的命名空间中?!为什么这个生成的代码不能编译?

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.296
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//-----------------------------------------------------------------------------

-

namespace ReminderServiceClient.ServiceReference1 {


[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="ServiceReference1.IReminderService")]
public interface IReminderService {

    [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IReminderService/DoWork", ReplyAction="http://tempuri.org/IReminderService/DoWorkResponse")]
    void DoWork();
}

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public interface IReminderServiceChannel : ReminderServiceClient.ServiceReference1.IReminderService, System.ServiceModel.IClientChannel {
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class ReminderServiceClient : System.ServiceModel.ClientBase<ReminderServiceClient.ServiceReference1.IReminderService>, ReminderServiceClient.ServiceReference1.IReminderService {

    public ReminderServiceClient() {
    }

    public ReminderServiceClient(string endpointConfigurationName) : 
            base(endpointConfigurationName) {
    }

    public ReminderServiceClient(string endpointConfigurationName, string remoteAddress) : 
            base(endpointConfigurationName, remoteAddress) {
    }

    public ReminderServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
            base(endpointConfigurationName, remoteAddress) {
    }

    public ReminderServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
            base(binding, remoteAddress) {
    }

    public void DoWork() {
        base.Channel.DoWork();
    }
}

}

4

1 回答 1

1

看起来它没有编译,因为生成的服务客户端类与项目具有相同的名称,因此它被命名空间和具有相同名称的类混淆了。边缘案例!

于 2013-02-18T18:43:11.960 回答