2013-02-14 63 views
0

這是Visual Studio在向項目添加服務引用時生成的代碼。 'ReminderServiceClient.ServiceReference1.IReminderService'的所有引用都不起作用,因爲它找不到'ServiceReference1'。但是它在頂部的命名空間中定義?!爲什麼這個生成的代碼不能編譯?WCF服務引用生成的代碼無法編譯

//------------------------------------------------------------------------------ 
// <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(); 
    } 
} 

}

+0

此外,您將什麼樣的項目添加到服務引用?一個網站「項目」(文件 - >新網站)? – 2013-02-14 17:25:06

+0

@JohnSaunders在哪裏使用它?我將它添加到控制檯應用程序項目中。 – 2013-02-14 17:39:41

+0

我明白了。嘗試做一個重建解決方案,看看是否有幫助。 – 2013-02-14 17:47:41

回答

1

看起來它並沒有因爲編譯生成的服務客戶端類具有相同的名稱作爲項目,所以它漸漸被命名混亂,該類具有相同的名稱。邊緣情況!