Hi Henchman 24,
I didn't reproduce your scenario.
1. I create one class library which contains service contract.
namespace ClassLibrary1
{
public enum PrimaryColor
{
Red,
Green,
Blue
};
[ServiceContract]
public interface ISimpleService
{
[OperationContract]
string SimpleMethod(string msg);
[OperationContract]
PrimaryColor GetColor();
}
}
2. I use Self-Host to start WCF service.
class SimpleService : ISimpleService
{
public string SimpleMethod(string msg)
{
Console.WriteLine("The caller passed in " + msg);
return "Hello " + msg;
}
public PrimaryColor GetColor()
{
return PrimaryColor.Red;
}
}
class Program
{
static void Main(string[] args)
{
ServiceHost svcHost = new ServiceHost(typeof(SimpleService), new Uri[]
{ new Uri("http://localhost:8006/MetadataSample")});
try
{
// Check to see if the service host already has a ServiceMetadataBehavior
ServiceMetadataBehavior smb = svcHost.Description.Behaviors.Find<ServiceMetadataBehavior>();
// If not, add one
if (smb == null)
smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
svcHost.Description.Behaviors.Add(smb);
// Add MEX endpoint
svcHost.AddServiceEndpoint(
ServiceMetadataBehavior.MexContractName,
MetadataExchangeBindings.CreateMexHttpBinding(),
"mex"
);
// Add application endpoint
svcHost.AddServiceEndpoint(typeof(ISimpleService), new WSHttpBinding(), "");
// Open the service host to accept incoming calls
svcHost.Open();
// The service can now be accessed.
Console.WriteLine("The service is ready.");
Console.WriteLine("Press <ENTER> to terminate service.");
Console.WriteLine();
Console.ReadLine();
// Close the ServiceHostBase to shutdown the service.
svcHost.Close();
}
catch (CommunicationException commProblem)
{
Console.WriteLine("There was a communication problem. " + commProblem.Message);
Console.Read();
}
}
3. I create the proxy class for the client via add service references with option "Reuse types in all referenced assemblies". The following is client code.
private void button1_Click(object sender, EventArgs e)
{
ServiceReference1.SimpleServiceClient sc = new ServiceReference1.SimpleServiceClient();
MessageBox.Show(sc.GetColor().ToString());
MessageBox.Show(sc.SimpleMethod("test"));
}
The client has reference to classlibrary1. We can see that there is not new enum type generated by IDE.
public ClassLibrary1.PrimaryColor GetColor() {
return base.Channel.GetColor();
}
Please check your code snippet. Or you can give one small code snippet so that we can reproduce your scenario.
Best regards,
Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.