Tuesday, October 31, 2006 2:59 AM
When I used wcf ,I wanted that the class which implemented the contract had a parameter constructor.But as I did this, I got a error.
Can anyone tell me how to realize what i want.
Tuesday, October 31, 2006 4:12 AM
WCF requires a parameterless constructor to dynamically instantiate a service contract implementation.
However, you do have some options:
1) You can pass in a self instantiated service contract (singleton) instance to the service host.
2) You can add a default constructor to your implementation and call a seperate init method to initialize the instance.
Tuesday, October 31, 2006 4:48 AM
Here is an example for Singleton with NetMsmqBinding:
UriqueueAddress = new Uri(ImportServiceURL); NetMsmqBinding msmqbinding = new NetMsmqBinding(NetMsmqSecurityMode.None);
msmqbinding.MaxReceivedMessageSize = 200 * 1024;
msmqbinding.QueueTransferProtocol =QueueTransferProtocol.Srmp; //Singleton instance with a non-default constructor DataExchangeService dxs = new DataExchangeService(ConnectionString);
m_hostImport =new ServiceHost(dxs, queueAddress); ServiceEndpoint sep = m_hostImport.AddServiceEndpoint(typeof(IDataExchange), msmqbinding, queueAddress); //sep.Behaviors.Add(new TransactedBatchingBehavior(1));
Wednesday, November 01, 2006 4:01 AM
Got it .
Thanks , Dave and T.Ramesh