Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Problem setting enum field value using Remoting

Problem setting enum field value using Remoting

Scheduled Pinned Locked Moved C#
helpcsharpdatabasedesignsysadmin
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    claughlin
    wrote on last edited by
    #1

    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

    H 1 Reply Last reply
    0
    • C claughlin

      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

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      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 the SerializableAttribute 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

      C 1 Reply Last reply
      0
      • H Heath Stewart

        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 the SerializableAttribute 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

        C Offline
        C Offline
        ClarkLaughlin
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups