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;
}
}