Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am trying to use duplex binding with Custom class.Service is throwing Exception.
If i Use System.object its working fine.When i use testInstance class as present in Duplexservice attached,its throwing exception.
Please help as i am stuck here.
Code snippet
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.ServiceModel;
using System.Threading;

namespace DuplexService
{
    [ServiceContract(CallbackContract = typeof(IClientCallback), Namespace = "http://Microsoft.ServiceModel.Samples")]
    public interface ITemperature
    {
        [OperationContract(IsOneWay = true)]
        void RegisterForTempDrops();
    }
<pre lang="text">

public interface IClientCallback
{
//[OperationContract(IsOneWay = true)]
//void TempUpdate(double temp);

[OperationContract]
bool TempUpdate(double temp);

[OperationContract]
bool ObjectUpdate(testInstance testobj);
}

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Reentrant)]
public class Temperature : ITemperature
{
public void RegisterForTempDrops()
{
OperationContext ctxt = OperationContext.Current;

IClientCallback callBack = ctxt.GetCallbackChannel<IClientCallback>();
Thread.Sleep(1000); //simulate update happens somewhere; for example monitoring a database field
callBack.TempUpdate(10);
//Thread.Sleep(1000); //simulate update happens somewhere; for example monitoring a database field
//IRtviCamera objRtviCamera = new RtviCamera("", "");
testInstance objInstance = new testInstance();
//object objtest = new object();
callBack.ObjectUpdate(objInstance);
}

}

[DataContract()]
[Serializable]
public class testInstance
{
[DataMember]
public string str1;

[DataMember]
public object obj;
}
}
Posted
Comments
sjelen 25-Oct-13 10:57am    
What exception is thrown?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900