none
WCF : ArgumentException : TransactionFlowProperty already exists RRS feed

  • Question


  • I have a self-hosted WCF Service with a peer-to-peer binding. I'm using a DuplexChannel for getting responses. The connection to the ServiceHost is working, but when the callback is being invoked I get the above mentioned ArgumentException, even though I'm not using any TransactionFlowProperties.

    [ServiceContract(SessionMode = SessionMode.Allowed, CallbackContract = typeof(ICallbackService))] public interface IService { [OperationContract(IsOneWay = true)] void Login(string email, string password); [OperationContract(IsOneWay = true)] void Logout(int userId); }

    [DataContract]

    public class User {

    [DataMember]

    public string Email {get; set;}

    [DataMember]

    public string Password {get; set;}

    } [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)] public class Service : IService { private static Dictionary<ICallbackService, ICallbackService> pair = new Dictionary<ICallbackService, ICallbackService>(); private static Dictionary<string, ICallbackService> clients = new Dictionary<string, ICallbackService>(); private ICallbackService callback; public Service(){} public void Login(string email, string password) { //User user = getAllUsers().Find(u => u.Email.ToLower() == email.ToLower() && u.Password == password); User user = new User(){Email = email, Password = password}; //this line is only for testing

    callback = OperationContext.Current.GetCallbackChannel<ICallbackService>(); if (user != null) { Console.WriteLine("user : " + email + " has logged in"); clients.Add(email, callback); callback.Authenticate(true); } else callback.Authenticate(false); } public void Logout(int userId) { string email = getUser(userId).Email; clients.Remove(email); stopService(); } } public interface ICallbackService { [OperationContract(IsOneWay = true)] void Authenticate(bool authenticated); } [CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Single, UseSynchronizationContext = false)] public class Client : Service.ICallbackService, { public bool Authentication { get; internal set; } public Client() { } public void Authenticate(bool authenticated) { Console.WriteLine("authentication : " + authenticated); Authentication = authenticated; } public class Proxy : IService { public Proxy(InstanceContext context) { init(context); } private void init(InstanceContext context) { NetPeerTcpBinding binding = new NetPeerTcpBinding(); binding.Security.Mode = SecurityMode.None; DuplexChannelFactory<IService> channel = new DuplexChannelFactory<IService>(context, binding, new EndpointAddress("net.p2p://Host")); service = channel.CreateChannel(); } public void Login(string email, string password) { service.Login(email, password); }

    public void Logout(int id)

    {

    service.Logout(id);

    } } public class User { ... public User() { client = new Client(); InstanceContext context = new InstanceContext(client); service = new Proxy(context); } public void Login(string email, string password) { service.Login(email, password); ... } } public class Server { public static void Main(string[] args) { ServiceHost host = host = new ServiceHost(typeof(Service)); NetPeerTcpBinding binding = new NetPeerTcpBinding(); binding.Security.Mode = SecurityMode.None; host.AddServiceEndpoint(new ServiceEndpoint(ContractDescription.GetContract(typeof(IService)), binding, new EndpointAddress("net.p2p://Host"))); host.Open(); Console.WriteLine("opened server ..."); Console.ReadLine(); } }

    The User class in the client application is different from the one in the server application.

      I couldn't find any solutions to this problem. Is there an alternative way to create a peer to peer application using a different binding ? The NetPeerTcpBinding seems to have some sort of a bug.






    • Edited by MerveShn Wednesday, June 1, 2016 1:33 PM
    Tuesday, May 31, 2016 11:02 PM

Answers

  • Hello,

    I have tested your code in my side, but I can not reproduce your issue in my side, it works fine as following:

    When you try to implement the callback, please make sure the service hosting application is running.
    Besides, please try to refer to the following article to see if you have missed something:
    #simple WCF P2P application:
    http://www.paulrohde.com/building-a-really-simple-wcf-p2p-application/ .

    Besides, I see that you have solved your problem in here:
    http://stackoverflow.com/questions/37532193/wcf-argumentexception-transactionflowproperty-already-exists .

    Best Regards,
    Amy Peng

    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Tuesday, June 7, 2016 3:17 AM
    Moderator

All replies

  • Hi MerveShn,

    According to your code snippet, I try to reproduce your issue on my side by using your code snippet, it seems that the code snippet is not complete, so that I couldn’t reproduce your issue. Could you please provide complete code.

    Best regards,

    Cole Wu


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, June 1, 2016 9:47 AM
  • Yes you're right I edited it now. But the exception is still occurring.
    Wednesday, June 1, 2016 1:29 PM
  • Hi cole wu,

    I edited the code, did you try it out?

    Saturday, June 4, 2016 9:21 PM
  • Hello,

    I have tested your code in my side, but I can not reproduce your issue in my side, it works fine as following:

    When you try to implement the callback, please make sure the service hosting application is running.
    Besides, please try to refer to the following article to see if you have missed something:
    #simple WCF P2P application:
    http://www.paulrohde.com/building-a-really-simple-wcf-p2p-application/ .

    Besides, I see that you have solved your problem in here:
    http://stackoverflow.com/questions/37532193/wcf-argumentexception-transactionflowproperty-already-exists .

    Best Regards,
    Amy Peng

    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Tuesday, June 7, 2016 3:17 AM
    Moderator