Reputation: 7692
I am trying to send an exception over the WCF wire but can't figure out what I have done wrong. I am following the guidance of Oleg Sych and MSDN but to no avail.
What I get back is The requested service, 'net.tcp://mymachine/myservicepath/MyService.svc' could not be activated. See the server's diagnostic trace logs for more information.
.
[ServiceContract]
public interface ISystemInfoService
{
[OperationContract]
[FaultContract(typeof(MyException))]
void DoThrowException(string message);
}
//[ServiceContract] // <- the culprit
public class SystemInfoService : ISystemInfoService
{
public void DoThrowException(string message)
{
try
{
throw new MyException( "MyMessage" );
}
catch (MyExceptionexc)
{
throw new FaultException<MyException>(exc);
}
}
}
// The custom Exception resides in an common assembly reachable from both server and client.
[Serializable]
public class MyException: Exception
{
...
}
TIA
Upvotes: 0
Views: 1067
Reputation: 5121
Can you try handling the exception with a datacontract class instead of serializable exception?
[DataContract]
public class MyExceptionClass
{
[DataMember]
public Exception Exc { get; set; }
}
[ServiceContract]
public interface ISystemInfoService
{
[OperationContract]
[FaultContract(typeof(MyExceptionClass))]
void DoThrowException(string message);
}
public class SystemInfoService : ISystemInfoService
{
public void DoThrowException(string message)
{
try
{
throw new Exception("MyMessage");
}
catch (Exception exc)
{
var data = new MyExceptionClass { Exc = exc };
throw new FaultException<MyExceptionClass>(data);
}
}
}
Upvotes: 1