Problem setting enum field value using Remoting
-
I am experiencing a very strange problem while trying to set the value of a public field in a class that is being accessed using .NET remoting. Assuming the following definitions: public enum BuildMethod { DropBox, CVS, } public class BuildInfo : System.MarshalByRefObject { /// public BuildMethod Method; ... } The problem occurs in my client when I am trying to set the value of the Method field of BuildInfo, i.e.: xxxx.Method = BuildMethod.DropBox; There does not appear to be a problem retrieving the value of the Method field, but only when I try to set it. Exception Details: System.Runtime.Remoting.RemotingException: The argument type 1 cannot be converted into parameter type Matrix.Definitions.Schema.BuildMethod. Stack Trace: [RemotingException: The argument type 1 cannot be converted into parameter type Matrix.Definitions.Schema.BuildMethod.] System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +264 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +877 System.Object.FieldSetter(String typeName, String fieldName, Object val) +0 Matrix.ProductMgmt.DeliveryMethodEditor.Save_Click(Object sender, EventArgs e) in D:\Matrix\WebApp\Application\ProductMgmt\DeliveryMethodEditor.ascx.cs:116 System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +108 System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +138 System.Web.UI.Page.ProcessRequestMain() +1277 I am setting up the channel on the server side like this: System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider SinkProvider = new BinaryServerFormatterSinkProvider(); SinkProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; IDictionary props = new Hashtable(); props["port"] = 10782; this.ServiceChannel = new TcpChannel(props, null, SinkProvider); ChannelServices.RegisterChannel(this.ServiceChannel); I am making the object available on the server side using RemotingServices.Marshal(). I would appreciate any help or suggestions that anyone can provide. Thank you, Clark Laughlin
-
I am experiencing a very strange problem while trying to set the value of a public field in a class that is being accessed using .NET remoting. Assuming the following definitions: public enum BuildMethod { DropBox, CVS, } public class BuildInfo : System.MarshalByRefObject { /// public BuildMethod Method; ... } The problem occurs in my client when I am trying to set the value of the Method field of BuildInfo, i.e.: xxxx.Method = BuildMethod.DropBox; There does not appear to be a problem retrieving the value of the Method field, but only when I try to set it. Exception Details: System.Runtime.Remoting.RemotingException: The argument type 1 cannot be converted into parameter type Matrix.Definitions.Schema.BuildMethod. Stack Trace: [RemotingException: The argument type 1 cannot be converted into parameter type Matrix.Definitions.Schema.BuildMethod.] System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +264 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +877 System.Object.FieldSetter(String typeName, String fieldName, Object val) +0 Matrix.ProductMgmt.DeliveryMethodEditor.Save_Click(Object sender, EventArgs e) in D:\Matrix\WebApp\Application\ProductMgmt\DeliveryMethodEditor.ascx.cs:116 System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +108 System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +138 System.Web.UI.Page.ProcessRequestMain() +1277 I am setting up the channel on the server side like this: System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider SinkProvider = new BinaryServerFormatterSinkProvider(); SinkProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; IDictionary props = new Hashtable(); props["port"] = 10782; this.ServiceChannel = new TcpChannel(props, null, SinkProvider); ChannelServices.RegisterChannel(this.ServiceChannel); I am making the object available on the server side using RemotingServices.Marshal(). I would appreciate any help or suggestions that anyone can provide. Thank you, Clark Laughlin
Does the remoting server have a reference to the
BuildMethod
Type? I suspect it either doens't know how to deserialize it (which reminds me, you really should be / have to be using theSerializableAttribute
on remotable objects) because it doesn't know the Type, or just doesn't recognize the Type to begin with. The client, on the other hand, would receive an integer representation of the enum and could deserialize that easily, as such is the case since your client can get the field.Microsoft MVP, Visual C# My Articles
-
Does the remoting server have a reference to the
BuildMethod
Type? I suspect it either doens't know how to deserialize it (which reminds me, you really should be / have to be using theSerializableAttribute
on remotable objects) because it doesn't know the Type, or just doesn't recognize the Type to begin with. The client, on the other hand, would receive an integer representation of the enum and could deserialize that easily, as such is the case since your client can get the field.Microsoft MVP, Visual C# My Articles
You know... I completely overlooked using SerializableAttribute on the enums -- that's probably what the problem is. I'll try it and let you know. Thank you for the suggestion. - Clark