Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. protected override void OnStart(string[] args)
  2. {
  3. // Expose remote object
  4. remotePool = new RemotePool();
  5. host = new ServiceHost(remotePool);
  6. host.Open();
  7. }
  8.  
  9. [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, AutomaticSessionShutdown = false)]
  10. public class RemotePool : IRemotePool, IDisposable
  11. {
  12. //...
  13. }
  14.  
  15. public string SomeFunction()
  16. {
  17. return WrapFunction(() => someFunctionThatMightThrowAnException());
  18. }
  19.  
  20. private T WrapFunction<T>(Func<T> func)
  21. {
  22. try
  23. {
  24. return func();
  25. }
  26. catch (Exception e)
  27. {
  28. throw new MyRemoteException(string.Join("n", UnwrapException(e)));
  29. }
  30. }
  31.  
  32. public class MyRemoteException : FaultException<MyServiceFault>
  33. {
  34. //...
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement