Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected override void OnStart(string[] args)
- {
- // Expose remote object
- remotePool = new RemotePool();
- host = new ServiceHost(remotePool);
- host.Open();
- }
- [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, AutomaticSessionShutdown = false)]
- public class RemotePool : IRemotePool, IDisposable
- {
- //...
- }
- public string SomeFunction()
- {
- return WrapFunction(() => someFunctionThatMightThrowAnException());
- }
- private T WrapFunction<T>(Func<T> func)
- {
- try
- {
- return func();
- }
- catch (Exception e)
- {
- throw new MyRemoteException(string.Join("n", UnwrapException(e)));
- }
- }
- public class MyRemoteException : FaultException<MyServiceFault>
- {
- //...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement