Ian Warburton
Ian Warburton

Reputation: 15716

WCF Service Reference generated code doesn't compile

This is the code generated by Visual Studio when I add a service reference to a project. All the references to 'ReminderServiceClient.ServiceReference1.IReminderService' don't work because it can't find 'ServiceReference1'. But its defined in the namespace at the top?! Why would this generated code not compile?

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

}

Upvotes: 0

Views: 577

Answers (1)

Ian Warburton
Ian Warburton

Reputation: 15716

Looks like it wasn't compiling because the generated service client class had the same name as the project and so it was getting confused by the namespace and the class having the same name. Edge case!

Upvotes: 1

Related Questions