.NET Remoting Exception not handled Client-Side
Posted
by DanJo519
on Stack Overflow
See other posts from Stack Overflow
or by DanJo519
Published on 2009-09-30T15:15:23Z
Indexed on
2010/04/25
0:43 UTC
Read the original article
Hit count: 830
I checked the rest of the remoting questions, and this specific case did not seem to be addressed.
I have a .NET Remoting server/client set up. On the server side I have an object with a method that can throw an exception, and a client which will try to call that method.
Server:
public bool MyEquals(Guid myGuid, string a, string b)
{
if (CheckAuthentication(myGuid))
{
logger.Debug("Request for \"" + a + "\".Equals(\"" + b + "\")");
return a.Equals(b);
}
else
{
throw new AuthenticationException(UserRegistryService.USER_NOT_REGISTERED_EXCEPTION_TEXT);
}
}
Client:
try
{
bool result = RemotedObject.MyEquals(myGuid, "cat", "dog");
}
catch (Services.Exceptions.AuthenticationException e)
{
Console.WriteLine("You do not have permission to execute that action");
}
When I call MyEquals with a Guid which causes CheckAuthentication to return false, .NET tries to throw the exception and says the AuthenticationException was unhandled. This happens server side. The exception is never marshaled over to the client-side, and I cannot figure out why. All of the questions I have looked at address the issue of an exception being handled client-side, but it isn't the custom exception but a base type. In my case, I can't even get any exception to cross the remoting boundary to the client. Here is a copy of AuthenticationException. It is in the shared library between both server and client.
[Serializable]
public class AuthenticationException : ApplicationException, ISerializable
{
public AuthenticationException(string message)
: base(message)
{
}
public AuthenticationException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
#region ISerializable Members
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
}
#endregion
}
© Stack Overflow or respective owner