We can send WCF messages from a client application(application that consumes the WCF service) even without creating a proxy object.
For that, we can use the ChannelFactory.
If we have a contract called IMycontract and there is a message called MyMessage in the Contract with the channel IMyChannel, follow these steps to send the message without SVCUtil.exe.
ChannelFactory<IMyChannel> factory = new ChannelFactory<IMyChannel>(new BasicHttpBinding());
IMyChannel channel = factory.CreateChannel(new EndpointAddress("http://10.10.10.10:2298/MyService/Service.svc"));
channel.MyMessage (param1, param2);
You can include the headers as well. The IMyChannel is derieved from IMyContract and System.ServiceModel.IClientChannel.
I am working lately a lot on Reflection and WCF. So there will be quite a few posts on around those two.
This is one relates to the former category.
Problem: You want to create a Combo Box at runtime and the items to be included in the Combo Box should be read from an enum.
Solution: Read the Enumeration at runtime and fill the items of the combo box with them.
First get all the values from the Enumeration:
String[] names = System.Enum.GetNames(typeof(enumToRead));
enumToRead is the Enum which you have to read the names from.
Now, iterating through each of the names, add it to the Combo Box:
foreach (string name in lstProvider)
{
cboxMyComboBox.Items.Add(name);
}
You can similarly get all the values in the enum by:
Array enumVal = Enum.GetValues(typeof(enumToRead)) ;
To retrieve the IP Address of the Machine on which the code is executed, you can use the following code:
string hostName = System.Net.Dns.GetHostName(); //get the name of the computerā¦
//gets the Ipaddress of the machineā¦
string IPAdd = System.Net.Dns.GetHostEntry(hostName ).AddressList[0].ToString();