internal static object ActivateWithMessage(Type serverType, IMessage msg, ServerIdentity srvIdToBind, out Exception e)
{
object obj1 = null;
e = null;
obj1 = RemotingServices.AllocateUninitializedObject(serverType);
object obj2 = null;
if (serverType.IsContextful)
{
if (msg is ConstructorCallMessage)
{
obj2 = ((ConstructorCallMessage) msg).GetThisPtr();
}
else
{
obj2 = null;
}
obj2 = RemotingServices.Wrap((ContextBoundObject) obj1, obj2, false);
}
else
{
if (Thread.CurrentContext != Context.DefaultContext)
{
throw new RemotingException(Environment.GetResourceString("Remoting_Activation_Failed"));
}
obj2 = obj1;
}
IMessageSink sink1 = new StackBuilderSink(obj2);
IMethodReturnMessage message1 = (IMethodReturnMessage) sink1.SyncProcessMessage(msg);
if (message1.Exception == null)
{
if (serverType.IsContextful)
{
return RemotingServices.Wrap((ContextBoundObject) obj1);
}
return obj1;
}
e = message1.Exception;
return null;
}